-
Notifications
You must be signed in to change notification settings - Fork 40
Backport to branch(3.16) : Fix behavior of group commit with one-phase commit #2845
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 crucial fix to address a behavioral issue when group commit is used in conjunction with one-phase commit. The changes ensure that the lifecycle of transactions within the group commit mechanism is correctly handled during one-phase commit attempts and executions, preventing potential inconsistencies. This also includes enabling and updating relevant test cases to validate the improved interaction between these features.
Highlights
- Group Commit and One-Phase Commit Interaction Fix: I've implemented a fix in
CommitHandlerWithGroupCommitto ensure that the group commit state is properly managed when one-phase commit operations are attempted or executed. Specifically,cancelGroupCommitIfNeededis now called whencanOnePhaseCommitthrows aCommitExceptionor whenonePhaseCommitRecordsis invoked, ensuring the transaction is correctly removed from the group commit queue. - Enabled Combined Feature Testing: Previously disabled test cases in
CommitHandlerWithGroupCommitTestthat combine one-phase commit and group commit functionalities have been re-enabled. This allows for comprehensive testing of the corrected behavior and validates the proper interaction between these two features. - Test Infrastructure Enhancements: I've introduced a new helper method,
createCommitHandlerWithOnePhaseCommit, inCommitHandlerTestand overridden it inCommitHandlerWithGroupCommitTestto streamline the setup of test scenarios involving one-phase commit. Additionally, assertions have been added to verify that thegroupCommitter.removemethod is called as expected during one-phase commit operations within group commit tests.
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 to address the behavior of group commit with one-phase commit. The changes include modifications to CommitHandlerWithGroupCommit.java and CommitHandlerTest.java to handle exceptions and ensure proper cancellation of group commits. Additionally, tests in CommitHandlerWithGroupCommitTest.java are updated to verify the interaction with the groupCommitter when one-phase commit is enabled.
| 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 re-throwing the exception after cancelling the group commit might mask the original stack trace, making debugging harder. Consider logging the caught exception before re-throwing it to preserve the context.
| boolean canOnePhaseCommit(Snapshot snapshot) throws CommitException { | |
| try { | |
| return super.canOnePhaseCommit(snapshot); | |
| } catch (CommitException e) { | |
| cancelGroupCommitIfNeeded(snapshot.getId()); | |
| throw e; | |
| } | |
| boolean canOnePhaseCommit(Snapshot snapshot) throws CommitException { | |
| try { | |
| return super.canOnePhaseCommit(snapshot); | |
| } catch (CommitException e) { | |
| logger.warn("canOnePhaseCommit failed", e); // Log the exception | |
| cancelGroupCommitIfNeeded(snapshot.getId()); | |
| throw e; | |
| } | |
| } |
| 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.
| @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.
| @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.
|
|
||
| @Test | ||
| public void | ||
| onePhaseCommitRecords_WhenRetriableExecutionExceptionThrown_ShouldThrowCommitConflictException() {} | ||
| @Override | ||
| public void canOnePhaseCommit_WhenMutationsCanBeGrouped_ShouldReturnTrue() throws Exception { | ||
| super.canOnePhaseCommit_WhenMutationsCanBeGrouped_ShouldReturnTrue(); | ||
| 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.
| @Test | ||
| @Override | ||
| public void canOnePhaseCommit_WhenMutationsCannotBeGrouped_ShouldReturnFalse() throws Exception { | ||
| super.canOnePhaseCommit_WhenMutationsCannotBeGrouped_ShouldReturnFalse(); | ||
| 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.
| @Test | ||
| @Override | ||
| public void | ||
| onePhaseCommitRecords_WhenExecutionExceptionThrown_ShouldThrowUnknownTransactionStatusException() {} | ||
| canOnePhaseCommit_WhenMutationsGrouperThrowsExecutionException_ShouldThrowCommitException() | ||
| throws ExecutionException { | ||
| super | ||
| .canOnePhaseCommit_WhenMutationsGrouperThrowsExecutionException_ShouldThrowCommitException(); | ||
|
|
||
| @Disabled("Enabling both one-phase commit and group commit is not supported") | ||
| @Override | ||
| @Test | ||
| public void commit_OnePhaseCommitted_ShouldNotThrowAnyException() {} | ||
| // 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.
| @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.
| @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.
This is an automated backport of the following:
Please merge this PR after all checks have passed.