Skip to content

Conversation

@feeblefakie
Copy link
Contributor

This is an automated backport of the following:

Please merge this PR after all checks have passed.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a 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 CommitHandlerWithGroupCommit now 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 CommitHandlerWithGroupCommitTest suite 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

  1. 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.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a 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.

Comment on lines +61 to +67
boolean canOnePhaseCommit(Snapshot snapshot) throws CommitException {
try {
return super.canOnePhaseCommit(snapshot);
} catch (CommitException e) {
cancelGroupCommitIfNeeded(snapshot.getId());
throw e;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

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.

Suggested change
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
}
}

Comment on lines +93 to +96
protected CommitHandler createCommitHandlerWithOnePhaseCommit() {
return new CommitHandler(
storage, coordinator, tableMetadataManager, parallelExecutor, mutationsGrouper, true, true);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

This method createCommitHandlerWithOnePhaseCommit is duplicated in CommitHandlerTest.java and CommitHandlerWithGroupCommitTest.java. Consider creating this method in a common base class to avoid duplication.

Comment on lines 216 to +224
@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());
}
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

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.

Suggested change
@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();
}

Comment on lines 226 to +235
@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());
}
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

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.

Suggested change
@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();
}

Comment on lines 237 to +246
@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());
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

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.

Suggested change
@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();
}

Comment on lines +248 to +258

@Test
@Override
public void
onePhaseCommitRecords_WhenExecutionExceptionThrown_ShouldThrowUnknownTransactionStatusException()
throws ExecutionException {
super
.onePhaseCommitRecords_WhenExecutionExceptionThrown_ShouldThrowUnknownTransactionStatusException();

// Assert
verify(groupCommitter).remove(anyId());
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

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();
  }

Comment on lines +316 to +322
@Test
@Override
public void commit_OnePhaseCommitted_ShouldNotThrowAnyException()
throws CommitException, UnknownTransactionStatusException {
super.commit_OnePhaseCommitted_ShouldNotThrowAnyException();
groupCommitter.remove(anyId());
}
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

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();
  }

Comment on lines 324 to +331
@Test
@Override
public void
commit_OnePhaseCommitted_UnknownTransactionStatusExceptionThrown_ShouldThrowUnknownTransactionStatusException() {}
commit_OnePhaseCommitted_UnknownTransactionStatusExceptionThrown_ShouldThrowUnknownTransactionStatusException()
throws CommitException, UnknownTransactionStatusException {
super
.commit_OnePhaseCommitted_UnknownTransactionStatusExceptionThrown_ShouldThrowUnknownTransactionStatusException();
groupCommitter.remove(anyId());
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

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();
  }

@brfrn169 brfrn169 merged commit da4a020 into 3 Jul 9, 2025
56 checks passed
@brfrn169 brfrn169 deleted the 3-pull-2832 branch July 9, 2025 10:21
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.

2 participants