-
Notifications
You must be signed in to change notification settings - Fork 40
Backport to branch(3) : Fix behavior of group commit with one-phase commit #2846
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
Conversation
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.
Summary of Changes
Hello @feeblefakie, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!
This pull request backports a critical fix that resolves the behavioral issues when combining the group commit and one-phase commit features. The changes ensure that the internal state of group commit is correctly managed and cleaned up during one-phase commit operations, thereby enabling the stable use of both features together. The accompanying test updates validate this corrected behavior.
Highlights
- Enabling One-Phase Commit with Group Commit: This pull request enables the use of one-phase commit alongside the group commit feature, which was previously considered unsupported. This is a significant change allowing for more flexible transaction configurations.
- Correct Group Commit State Management: The
CommitHandlerWithGroupCommitnow explicitly ensures that the group commit state is properly canceled or removed (cancelGroupCommitIfNeeded) during one-phase commit operations. This cleanup occurs both when checking if one-phase commit is possible and when performing the commit, even if exceptions are thrown. - Comprehensive Test Suite Updates: Numerous previously disabled tests related to one-phase commit within the
CommitHandlerWithGroupCommitTestsuite have been re-enabled. These tests now include assertions to verify that the group commit state is correctly managed and cleaned up after one-phase commit attempts, whether successful or failed.
Using Gemini Code Assist
The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.
Invoking Gemini
You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.
| Feature | Command | Description |
|---|---|---|
| Code Review | /gemini review |
Performs a code review for the current pull request in its current state. |
| Pull Request Summary | /gemini summary |
Provides a summary of the current pull request in its current state. |
| Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in issue comments and review comments. |
| Help | /gemini help |
Displays a list of available commands. |
Customization
To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.
Limitations & Feedback
Gemini Code Assist is currently in preview and may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments to provide feedback.
You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.
Footnotes
-
Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩
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.
Code Review
The pull request backports a fix related to the behavior of group commit with one-phase commit. The changes include modifications to the CommitHandlerWithGroupCommit class to handle exceptions during one-phase commit and updates to the test classes to reflect the changes in behavior. The code review identified opportunities to reduce redundancy and improve readability.
| boolean canOnePhaseCommit(Snapshot snapshot) throws CommitException { | ||
| try { | ||
| return super.canOnePhaseCommit(snapshot); | ||
| } catch (CommitException e) { | ||
| cancelGroupCommitIfNeeded(snapshot.getId()); | ||
| throw e; | ||
| } |
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.
Wrapping the call to super.canOnePhaseCommit in a try-catch block and then throwing the caught exception is redundant. You can simplify this by directly throwing the exception after canceling the group commit if needed.
Also, consider logging the exception before re-throwing it to aid in debugging.
| boolean canOnePhaseCommit(Snapshot snapshot) throws CommitException { | |
| try { | |
| return super.canOnePhaseCommit(snapshot); | |
| } catch (CommitException e) { | |
| cancelGroupCommitIfNeeded(snapshot.getId()); | |
| throw e; | |
| } | |
| @Override | |
| boolean canOnePhaseCommit(Snapshot snapshot) throws CommitException { | |
| try { | |
| return super.canOnePhaseCommit(snapshot); | |
| } catch (CommitException e) { | |
| cancelGroupCommitIfNeeded(snapshot.getId()); | |
| throw e; // Re-throw the exception | |
| } | |
| } |
| protected CommitHandler createCommitHandlerWithOnePhaseCommit() { | ||
| return new CommitHandler( | ||
| storage, coordinator, tableMetadataManager, parallelExecutor, mutationsGrouper, true, true); | ||
| } |
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.
| @Test | ||
| public void canOnePhaseCommit_WhenOnePhaseCommitDisabled_ShouldReturnFalse() {} | ||
|
|
||
| @Disabled("Enabling both one-phase commit and group commit is not supported") | ||
| @Override | ||
| @Test | ||
| public void canOnePhaseCommit_WhenValidationRequired_ShouldReturnFalse() {} | ||
| public void onePhaseCommitRecords_WhenSuccessful_ShouldMutateUsingComposerMutations() | ||
| throws CommitConflictException, UnknownTransactionStatusException, ExecutionException { | ||
| super.onePhaseCommitRecords_WhenSuccessful_ShouldMutateUsingComposerMutations(); | ||
|
|
||
| @Disabled("Enabling both one-phase commit and group commit is not supported") | ||
| @Override | ||
| @Test | ||
| public void canOnePhaseCommit_WhenNoWritesAndDeletes_ShouldReturnFalse() {} | ||
| // Assert | ||
| verify(groupCommitter).remove(anyId()); | ||
| } |
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 verify(groupCommitter).remove(anyId()) call is made after calling the super method. It would be more readable if this was done before the super method call, to clearly indicate the order of operations.
| @Test | |
| public void canOnePhaseCommit_WhenOnePhaseCommitDisabled_ShouldReturnFalse() {} | |
| @Disabled("Enabling both one-phase commit and group commit is not supported") | |
| @Override | |
| @Test | |
| public void canOnePhaseCommit_WhenValidationRequired_ShouldReturnFalse() {} | |
| public void onePhaseCommitRecords_WhenSuccessful_ShouldMutateUsingComposerMutations() | |
| throws CommitConflictException, UnknownTransactionStatusException, ExecutionException { | |
| super.onePhaseCommitRecords_WhenSuccessful_ShouldMutateUsingComposerMutations(); | |
| @Disabled("Enabling both one-phase commit and group commit is not supported") | |
| @Override | |
| @Test | |
| public void canOnePhaseCommit_WhenNoWritesAndDeletes_ShouldReturnFalse() {} | |
| // Assert | |
| verify(groupCommitter).remove(anyId()); | |
| } | |
| @Test | |
| @Override | |
| public void onePhaseCommitRecords_WhenSuccessful_ShouldMutateUsingComposerMutations() | |
| throws CommitConflictException, UnknownTransactionStatusException, ExecutionException { | |
| // Assert | |
| verify(groupCommitter).remove(anyId()); | |
| super.onePhaseCommitRecords_WhenSuccessful_ShouldMutateUsingComposerMutations(); | |
| } |
| @Test | ||
| public void canOnePhaseCommit_WhenDeleteWithoutExistingRecord_ShouldReturnFalse() {} | ||
|
|
||
| @Disabled("Enabling both one-phase commit and group commit is not supported") | ||
| @Override | ||
| @Test | ||
| public void canOnePhaseCommit_WhenMutationsCanBeGrouped_ShouldReturnTrue() {} | ||
| public void | ||
| onePhaseCommitRecords_WhenNoMutationExceptionThrown_ShouldThrowCommitConflictException() | ||
| throws ExecutionException { | ||
| super.onePhaseCommitRecords_WhenNoMutationExceptionThrown_ShouldThrowCommitConflictException(); | ||
|
|
||
| @Disabled("Enabling both one-phase commit and group commit is not supported") | ||
| @Override | ||
| @Test | ||
| public void canOnePhaseCommit_WhenMutationsCannotBeGrouped_ShouldReturnFalse() {} | ||
| // Assert | ||
| verify(groupCommitter).remove(anyId()); | ||
| } |
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 verify(groupCommitter).remove(anyId()) call is made after calling the super method. It would be more readable if this was done before the super method call, to clearly indicate the order of operations.
| @Test | |
| public void canOnePhaseCommit_WhenDeleteWithoutExistingRecord_ShouldReturnFalse() {} | |
| @Disabled("Enabling both one-phase commit and group commit is not supported") | |
| @Override | |
| @Test | |
| public void canOnePhaseCommit_WhenMutationsCanBeGrouped_ShouldReturnTrue() {} | |
| public void | |
| onePhaseCommitRecords_WhenNoMutationExceptionThrown_ShouldThrowCommitConflictException() | |
| throws ExecutionException { | |
| super.onePhaseCommitRecords_WhenNoMutationExceptionThrown_ShouldThrowCommitConflictException(); | |
| @Disabled("Enabling both one-phase commit and group commit is not supported") | |
| @Override | |
| @Test | |
| public void canOnePhaseCommit_WhenMutationsCannotBeGrouped_ShouldReturnFalse() {} | |
| // Assert | |
| verify(groupCommitter).remove(anyId()); | |
| } | |
| @Test | |
| @Override | |
| public void | |
| onePhaseCommitRecords_WhenNoMutationExceptionThrown_ShouldThrowCommitConflictException() | |
| throws ExecutionException { | |
| // Assert | |
| verify(groupCommitter).remove(anyId()); | |
| super.onePhaseCommitRecords_WhenNoMutationExceptionThrown_ShouldThrowCommitConflictException(); | |
| } |
| @Test | ||
| public void canOnePhaseCommit_WhenMutationsGrouperThrowsException_ShouldThrowCommitException() {} | ||
| @Override | ||
| public void | ||
| onePhaseCommitRecords_WhenRetriableExecutionExceptionThrown_ShouldThrowCommitConflictException() | ||
| throws ExecutionException { | ||
| super | ||
| .onePhaseCommitRecords_WhenRetriableExecutionExceptionThrown_ShouldThrowCommitConflictException(); | ||
|
|
||
| @Disabled("Enabling both one-phase commit and group commit is not supported") | ||
| // Assert | ||
| verify(groupCommitter).remove(anyId()); |
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 verify(groupCommitter).remove(anyId()) call is made after calling the super method. It would be more readable if this was done before the super method call, to clearly indicate the order of operations.
| @Test | |
| public void canOnePhaseCommit_WhenMutationsGrouperThrowsException_ShouldThrowCommitException() {} | |
| @Override | |
| public void | |
| onePhaseCommitRecords_WhenRetriableExecutionExceptionThrown_ShouldThrowCommitConflictException() | |
| throws ExecutionException { | |
| super | |
| .onePhaseCommitRecords_WhenRetriableExecutionExceptionThrown_ShouldThrowCommitConflictException(); | |
| @Disabled("Enabling both one-phase commit and group commit is not supported") | |
| // Assert | |
| verify(groupCommitter).remove(anyId()); | |
| @Test | |
| @Override | |
| public void | |
| onePhaseCommitRecords_WhenRetriableExecutionExceptionThrown_ShouldThrowCommitConflictException() | |
| throws ExecutionException { | |
| // Assert | |
| verify(groupCommitter).remove(anyId()); | |
| super | |
| .onePhaseCommitRecords_WhenRetriableExecutionExceptionThrown_ShouldThrowCommitConflictException(); | |
| } |
|
|
||
| @Test | ||
| @Override | ||
| public void | ||
| onePhaseCommitRecords_WhenExecutionExceptionThrown_ShouldThrowUnknownTransactionStatusException() | ||
| throws ExecutionException { | ||
| super | ||
| .onePhaseCommitRecords_WhenExecutionExceptionThrown_ShouldThrowUnknownTransactionStatusException(); | ||
|
|
||
| // Assert | ||
| verify(groupCommitter).remove(anyId()); |
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 verify(groupCommitter).remove(anyId()) call is made after calling the super method. It would be more readable if this was done before the super method call, to clearly indicate the order of operations.
@Test
@Override
public void
onePhaseCommitRecords_WhenExecutionExceptionThrown_ShouldThrowUnknownTransactionStatusException()
throws ExecutionException {
// Assert
verify(groupCommitter).remove(anyId());
super
.onePhaseCommitRecords_WhenExecutionExceptionThrown_ShouldThrowUnknownTransactionStatusException();
}| @Test | ||
| @Override | ||
| public void commit_OnePhaseCommitted_ShouldNotThrowAnyException() | ||
| throws CommitException, UnknownTransactionStatusException { | ||
| super.commit_OnePhaseCommitted_ShouldNotThrowAnyException(); | ||
| groupCommitter.remove(anyId()); | ||
| } |
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 groupCommitter.remove(anyId()) call is made after calling the super method. It would be more readable if this was done before the super method call, to clearly indicate the order of operations.
@Test
@Override
public void commit_OnePhaseCommitted_ShouldNotThrowAnyException()
throws CommitException, UnknownTransactionStatusException {
// Assert
groupCommitter.remove(anyId());
super.commit_OnePhaseCommitted_ShouldNotThrowAnyException();
}| @Test | ||
| @Override | ||
| public void | ||
| commit_OnePhaseCommitted_UnknownTransactionStatusExceptionThrown_ShouldThrowUnknownTransactionStatusException() {} | ||
| commit_OnePhaseCommitted_UnknownTransactionStatusExceptionThrown_ShouldThrowUnknownTransactionStatusException() | ||
| throws CommitException, UnknownTransactionStatusException { | ||
| super | ||
| .commit_OnePhaseCommitted_UnknownTransactionStatusExceptionThrown_ShouldThrowUnknownTransactionStatusException(); | ||
| groupCommitter.remove(anyId()); |
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 groupCommitter.remove(anyId()) call is made after calling the super method. It would be more readable if this was done before the super method call, to clearly indicate the order of operations.
@Test
@Override
public void
commit_OnePhaseCommitted_UnknownTransactionStatusExceptionThrown_ShouldThrowUnknownTransactionStatusException()
throws CommitException, UnknownTransactionStatusException {
// Assert
groupCommitter.remove(anyId());
super
.commit_OnePhaseCommitted_UnknownTransactionStatusExceptionThrown_ShouldThrowUnknownTransactionStatusException();
}
This is an automated backport of the following:
Please merge this PR after all checks have passed.