-
Notifications
You must be signed in to change notification settings - Fork 37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Optimize Coordinator#getStateForGroupCommit()
by first looking up the coordinator table with parent transaction ID
#2331
Optimize Coordinator#getStateForGroupCommit()
by first looking up the coordinator table with parent transaction ID
#2331
Conversation
Coordinator#getStateForGroupCommit()
by first looking up the coordinator table with parent transaction ID
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Thank you!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thank you!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code looks good!
I left a suggestion on the comment.
PTAL!
} | ||
return Optional.empty(); | ||
}); | ||
// The current implementation is optimized for cases where the target transaction is properly |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment is a bit hard to follow to me, so can it be something like this?
Please also verify if it is correct.
The current implementation is optimized for a case where most transactions are group-committed.
Specifically, Coordinator first checks a transaction state by using a parent ID with one read operation.
If it cannot find it, which means the transaction is delayed and not included in a group, it will issue an additional read operation by using the full ID.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@feeblefakie Thanks! It seems better.
How about the following version revised based on your suggestion?
The current implementation is optimized for cases where most transactions are group-committed. It first looks up a transaction state by the parent ID with a single read operation. If no matching transaction state is found (i.e., the transaction was delayed and committed individually), it issues an additional read operation using the full ID.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated the comment in 1b62d3c
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks good!
Just one thing. Let's use consistent wording (using xxx ID).
The current implementation is optimized for cases where most transactions are group-committed. It first looks up a transaction state using the parent ID with a single read operation. If no matching transaction state is found (i.e., the transaction was delayed and committed individually), it issues an additional read operation using the full ID.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Fixed it in 6e3ece2.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left a comment on the Javadoc comment, other than that LGTM! Thank you!
…he coordinator table with parent transaction ID (#2331)
Description
The current implementation of
Coordinator.getStateForGroupCommit()
checks transaction states that were stored with the Group Commit feature enabled in the following order:tx_id
is the full transaction ID, returning the state if it's found. This record type is created when a transaction is delayed and committed individually.tx_id
is the parent transaction ID, returning the state if it's found and thetx_sub_ids
contains the child transaction ID. This record type is created when a transaction gets commit-ready in time and group-committed.This order is optimized for lazy-recovery, which is more likely to happen if the commit timing is delayed after PREPARE record is created. However, basically lazy-recovery doesn't happen so often.
We may create a new system that frequently looks up the coordinator table in the future. In that case, it might need to prioritize first finding group-committed transactions, not just delayed individually committed transaction. The current order doesn't fit this scenario.
This PR changes the lookup order to prioritize group-committed transactions first.
Related issues and/or PRs
None
Changes made
Coordinator#getStateForGroupCommit()
.Checklist
Additional notes (optional)
None
Release notes
N/A