Skip to content

HDDS-11712. Process other DeletedBlocksTransaction before retrying failed one - #7532

Merged
nandakumar131 merged 7 commits into
apache:masterfrom
ashishkumar50:HDDS-11712
Dec 17, 2024
Merged

HDDS-11712. Process other DeletedBlocksTransaction before retrying failed one#7532
nandakumar131 merged 7 commits into
apache:masterfrom
ashishkumar50:HDDS-11712

Conversation

@ashishkumar50

Copy link
Copy Markdown
Contributor

What changes were proposed in this pull request?

In few cases when some transactions are problematic, that leads to block other transactions to be processed until it reaches max retry. To overcome this bottleneck we can give each transaction to get chance before same transaction being retried again.

What is the link to the Apache JIRA

https://issues.apache.org/jira/browse/HDDS-11712

How was this patch tested?

New unit test

@adoroszlai adoroszlai changed the title HDDS-11712. Iterate whole scm delete block table in SCMBlockDeletingService before retrying the same transaction again. HDDS-11712. Process other DeletedBlocksTransaction before retrying failed one Dec 5, 2024
Comment on lines +402 to +413
try (TableIterator<Long,
? extends Table.KeyValue<Long, DeletedBlocksTransaction>> tmpIter =
deletedBlockLogStateManager.getReadOnlyIterator()) {
if (tmpIter.hasNext()) {
keyValue = tmpIter.next();
if (keyValue.getKey() != firstProcessedTransactionKey) {
iter.seek(keyValue.getKey());
} else {
break;
}
}
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
try (TableIterator<Long,
? extends Table.KeyValue<Long, DeletedBlocksTransaction>> tmpIter =
deletedBlockLogStateManager.getReadOnlyIterator()) {
if (tmpIter.hasNext()) {
keyValue = tmpIter.next();
if (keyValue.getKey() != firstProcessedTransactionKey) {
iter.seek(keyValue.getKey());
} else {
break;
}
}
}
iter.seekToFirst();

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nandakumar131 Thanks for the suggestion, handled it.

@ashishkumar50

Copy link
Copy Markdown
Contributor Author

There is some issue in latest change, looking into it.

@ashishkumar50

Copy link
Copy Markdown
Contributor Author

Fixed the issue, @nandakumar131 can you please help to relook.

? extends Table.KeyValue<Long, DeletedBlocksTransaction>> iter =
deletedBlockLogStateManager.getReadOnlyIterator()) {
if (nextProcessTransactionId != -1) {
iter.seek(nextProcessTransactionId);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a possibility that the nextProcessTransactionId is deleted from the table. In that case comparing nextProcessTransactionId with keyValue.getKey() will make no sense.

Comment on lines +409 to +421
if (!iter.hasNext()) {
iter.seekToFirst();
if (transactions.getBlocksDeleted() >= blockDeletionLimit) {
nextProcessTransactionId = -1;
}
}
}
if (iter.hasNext() && nextProcessTransactionId != -1) {
// Store this value so that next iteration starts from this element instead of beginning
nextProcessTransactionId = iter.next().getKey();
} else {
// No more element in the table, start next iteration from the beginning
nextProcessTransactionId = -1L;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can understand the idea here after spending some time going over the logic, but this is not easy to follow.

Comment on lines +370 to +374
if (nextProcessTransactionId == keyValue.getKey() && !firstTime) {
// Before already processed this transactionId in the current iteration.
// Table is completely iterated once
nextProcessTransactionId = -1;
break;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the nextProcessTransactionId is removed form the table, we will not break here. This will end up adding duplicate entries into the transaction.

@nandakumar131

Copy link
Copy Markdown
Contributor

@ashishkumar50, thanks for working on this and also working on the review comments.
I tried to simplify the logic and make it easy to understand, please take a look at this - 0debb78

@ashishkumar50

ashishkumar50 commented Dec 13, 2024

Copy link
Copy Markdown
Contributor Author

@nandakumar131 Thanks for simplifying by skip processing the new lastTransactionId in some cases.
One thing i think needs to corrected:
This is not setting correctly in below case
lastProcessedTransactionId = keyValue != null ? keyValue.getKey() : -1;

Assume there are 15 transactions.
And SCM returns maximum 10 transactions in one run.
In this case transaction 1-10 is returned back and lastProcessedTransactionId is set it as 10
In second run, again lastProcessedTransactionId is set it as 10.
I think it should set it as -1?

@ashishkumar50

Copy link
Copy Markdown
Contributor Author

@nandakumar131 Thanks for simplifying by skip processing the new lastTransactionId in some cases. One thing i think needs to corrected: This is not setting correctly in below case lastProcessedTransactionId = keyValue != null ? keyValue.getKey() : -1;

Assume there are 15 transactions. And SCM returns maximum 10 transactions in one run. In this case transaction 1-10 is returned back and lastProcessedTransactionId is set it as 10 In second run, again lastProcessedTransactionId is set it as 10. I think it should set it as -1?

I think above case is fine, as it will get next available transaction after 10th transaction to start next run which is fine.

@nandakumar131, I have updated PR with your change. Can you please check.

@nandakumar131
nandakumar131 merged commit 8bb0587 into apache:master Dec 17, 2024
@nandakumar131

Copy link
Copy Markdown
Contributor

Thanks @ashishkumar50 for the contribution and thanks to @adoroszlai for the review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants