Skip to content

Conversation

@brfrn169
Copy link
Collaborator

@brfrn169 brfrn169 commented Nov 4, 2025

Description

This PR unifies the Get/Scan preparation logic used during transaction reads and Serializable validation by introducing common utility methods in ConsensusCommitUtils. Previously, these two processes prepared Get/Scan objects differently, which could result in inconsistent ordering and cause Serializable validation failures.

Related issues and/or PRs

N/A

Changes made

  • Added ConsensusCommitUtils.prepareGetForStorage()
  • Added ConsensusCommitUtils.prepareScanForStorage()
  • Updated CrudHander and Snapshot to use ConsensusCommitUtils.prepareGetForStorage() and ConsensusCommitUtils.prepareScanForStorage() to use the same Scan and Get between transaction reads and Serializable validation.

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

Fixed an inconsistency where Get and Scan operations were prepared differently for transaction reads and Serializable validation, which could result in inconsistent ordering and cause Serializable validation failures.

@brfrn169 brfrn169 self-assigned this Nov 4, 2025
Copilot AI review requested due to automatic review settings November 4, 2025 16:04
@brfrn169 brfrn169 added the bugfix label Nov 4, 2025
@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 to centralize and unify the preparation logic for Get and Scan operations within the Consensus Commit transaction protocol. By moving this logic to ConsensusCommitUtils, the CrudHandler becomes cleaner and more focused on its core responsibilities. This change particularly enhances the handling of conditional expressions and before-image columns during storage reads and serializable validation, ensuring correctness and improving maintainability.

Highlights

  • Unification of Get/Scan Preparation Logic: The logic for preparing Get and Scan operations for storage reads, including handling conditional expressions and before-image columns for serializable validation, has been centralized into ConsensusCommitUtils.
  • Refactored CrudHandler: The CrudHandler methods (get, scan, readUnread, read, getFromStorage, scanFromStorage, getScanner, put, delete, readIfImplicitPreReadEnabled) now delegate the storage preparation to the new utility methods in ConsensusCommitUtils. This simplifies CrudHandler and improves modularity.
  • Improved Scan Limit Handling: The prepareScanForStorage method now explicitly removes any set limit from Scan operations when conjunctions are present. This ensures that all relevant records, including those with before-images, are retrieved from storage before filtering, which is crucial for correct recovery and validation.
  • Simplified Serializable Validation: The Snapshot validation logic for serializable isolation now leverages the unified prepareGetForStorage and prepareScanForStorage methods, ensuring consistent preparation of operations during validation checks.
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 is a nice refactoring that unifies the logic for preparing Get and Scan operations. However, this unification has introduced a performance regression in the validation logic for serializable transactions. The validation scans and gets now fetch all columns from storage, whereas previously they only fetched the columns necessary for validation. I've added a couple of review comments with suggestions to address this inefficiency while retaining the benefits of the refactoring.

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.

Pull Request Overview

This PR refactors how Get and Scan operations are prepared for storage in consensus commit transactions. The main changes include:

  • Extracting conjunction conversion logic from CrudHandler to ConsensusCommitUtils for reusability
  • Moving projection clearing and consistency setting to new utility methods prepareGetForStorage and prepareScanForStorage
  • Updating test expectations to reflect that operations passed to storage now use the original Get/Scan for snapshot tracking instead of the storage-prepared version

Reviewed Changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
ConsensusCommitSpecificIntegrationTestBase.java Fixed bug where manager.get() was incorrectly called instead of transaction.get()
SnapshotTest.java Removed redundant consistency settings and updated test expectations to use original operations for tracking
CrudHandlerTest.java Updated test expectations to pass original operations to snapshot methods and added conjunction handling tests
ConsensusCommitUtilsTest.java Added comprehensive tests for new prepareGetForStorage and prepareScanForStorage utility methods
Snapshot.java Refactored validation logic to use new utility methods and added conjunction filtering
CrudHandler.java Refactored to use new utility methods and pass original operations to snapshot
ConsensusCommitUtils.java Added new utility methods for preparing Get/Scan operations for storage with conjunction conversion

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@brfrn169 brfrn169 requested a review from komamitsu November 5, 2025 11:16
Copy link
Contributor

@komamitsu komamitsu left a comment

Choose a reason for hiding this comment

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

LGTM! 👍

Copy link
Contributor

@Torch3333 Torch3333 left a comment

Choose a reason for hiding this comment

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

LGTM, thank you!

Copy link
Contributor

@feeblefakie feeblefakie left a comment

Choose a reason for hiding this comment

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

LGTM! Thank you!

@brfrn169 brfrn169 merged commit 477fba5 into master Nov 7, 2025
130 of 132 checks passed
@brfrn169 brfrn169 deleted the unify-get-scan-preparation-logic-for-transaction-reads-and-serializable-validation branch November 7, 2025 14:11
feeblefakie pushed a commit that referenced this pull request Nov 7, 2025
brfrn169 added a commit that referenced this pull request Nov 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants