Skip to content

Conversation

@brfrn169
Copy link
Collaborator

@brfrn169 brfrn169 commented Nov 25, 2025

Description

This PR extends the applicability of one-phase commit optimization in the Consensus Commit protocol.

Previously, one-phase commit optimization was not available when the isolation level is SERIALIZABLE. This change enables one-phase commit even in SERIALIZABLE isolation level when validation is not actually needed. This change will improve transaction performance in SERIALIZABLE isolation level for read-modify-write workloads.

Related issues and/or PRs

N/A

Changes made

  • Moved validation logic from Snapshot to CommitHandler: The toSerializable() method and related validation logic have been relocated to CommitHandler, making the validation process more centralized and easier to manage.
  • Introduced ValidationInfo class: This new class encapsulates the information needed for validation and provides the isActuallyValidationRequired() method to determine if validation is truly necessary.
  • Updated canOnePhaseCommit() logic: The method now uses ValidationInfo.isActuallyValidationRequired() instead of TransactionContext.isValidationRequired(), enabling one-phase commit when validation is configured but not actually needed.

Checklist

The following is a best-effort checklist. If any items in this checklist are not applicable to this PR or are dependent on other, unmerged PRs, please still mark the checkboxes after you have read and understood each item.

  • I have commented my code, particularly in hard-to-understand areas.
  • I have updated the documentation to reflect the changes.
  • I have considered whether similar issues could occur in other products, components, or modules if this PR is for bug fixes.
  • Any remaining open issues linked to this PR are documented and up-to-date (Jira, GitHub, etc.).
  • Tests (unit, integration, etc.) have been added for the changes.
  • My changes generate no new warnings.
  • Any dependent changes in other PRs have been merged and published.

Additional notes (optional)

N/A

Release notes

Extended the applicability of one-phase commit optimization in the Consensus Commit protocol. This allows one-phase commit to be used even in SERIALIZABLE isolation level when the transaction only reads records that it subsequently updates, improving performance for read-modify-write workloads.

@brfrn169 brfrn169 self-assigned this Nov 25, 2025
Copilot AI review requested due to automatic review settings November 25, 2025 05:56
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @brfrn169, 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 introduces a significant refactoring of the transaction commit and validation process. The primary goal is to extend the applicability of the one-phase commit optimization, allowing it to be utilized more broadly, especially for transactions operating under SERIALIZABLE isolation. By moving and refining the validation logic, the system can now intelligently determine when a full validation phase is truly necessary, thereby optimizing performance for transactions that don't inherently require it, without compromising correctness.

Highlights

  • Refactored Validation Logic: The transaction validation logic, previously residing in the Snapshot class, has been moved to the CommitHandler. This includes methods for validating read sets, scan sets, and indexed operations.
  • Extended One-Phase Commit Applicability: The one-phase commit optimization can now be applied to transactions under SERIALIZABLE isolation, provided that the transaction's read set does not actually require validation (e.g., if all read records are also modified by the same transaction). A new ValidationInfo class helps determine this.
  • Improved Performance for SERIALIZABLE Transactions: By allowing one-phase commit for certain SERIALIZABLE transactions, the number of storage operations during commit can be reduced, leading to potential performance improvements.
  • Updated Snapshot Class: The Snapshot class has been simplified by removing its direct dependency on Isolation level and ParallelExecutor, as well as the validation methods that were moved to CommitHandler.
  • Comprehensive Test Coverage: Extensive unit and integration tests have been added or updated to cover the new validation logic in CommitHandler and to verify the extended applicability of the one-phase commit optimization across various storage atomicity units.
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 by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

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 pull request 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 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. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

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

This pull request extends the applicability of the one-phase commit optimization to SERIALIZABLE transactions, provided that the read set only contains records that are also part of the write set. This is a significant performance improvement. The implementation involves refactoring the validation logic out of the Snapshot class and into the CommitHandler, using a new ValidationInfo helper class. The changes are well-structured and accompanied by thorough unit and integration tests. My review includes a few suggestions to improve robustness and maintainability, such as addressing a potential StackOverflowError from tail recursion, fixing a bug in an equals method used in tests, and refactoring test code to reduce duplication.

Copilot finished reviewing on behalf of brfrn169 November 25, 2025 06:03
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@brfrn169 brfrn169 changed the title Extend applicability of one-phase commit optimization Extend applicability of one-phase commit optimization in Consensus Commit Nov 25, 2025
@brfrn169 brfrn169 marked this pull request as draft November 25, 2025 06:56
@brfrn169 brfrn169 marked this pull request as ready for review November 26, 2025 13:55
@brfrn169 brfrn169 requested review from Copilot and removed request for Torch3333, feeblefakie and komamitsu November 26, 2025 13:55
@brfrn169
Copy link
Collaborator Author

/gemini review

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

This pull request introduces a valuable optimization for one-phase commits in SERIALIZABLE isolation level, specifically for read-modify-write workloads. The refactoring of moving validation logic from Snapshot to CommitHandler is a great design improvement, enhancing separation of concerns and making the code easier to maintain. The introduction of the ValidationInfo class further cleans up the validation process. The accompanying unit and integration tests are comprehensive and provide good coverage for these critical changes.

I have found one potential issue regarding a recursive method call that could lead to a StackOverflowError under certain data patterns. My review includes a specific comment and suggestion to address this. Overall, this is a high-quality contribution.

Copilot finished reviewing on behalf of brfrn169 November 26, 2025 14:05
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant