Skip to content

Conversation

@brfrn169
Copy link
Collaborator

Description

This PR adds support for beginning transactions in read-only mode. It simply merges the support-begin-in-read-only-mode feature branch into the master branch, and the code has already been reviewed.

Related issues and/or PRs

Changes made

  • Merged the support-begin-in-read-only-mode feature branch to the master branch

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

Added support for beginning transactions in read-only mode.

@brfrn169 brfrn169 self-assigned this Jun 10, 2025
@brfrn169 brfrn169 added the enhancement New feature or request label Jun 10, 2025
@brfrn169 brfrn169 changed the title Add support support for beginning transactions in read-only mode Add support for beginning transactions in read-only mode Jun 10, 2025
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 adds support for beginning transactions in read‐only mode by extending the transaction manager interfaces and implementations across multiple modules. It introduces new methods (beginReadOnly/startReadOnly) in core transaction manager classes, updates JDBC connection handling for read‐only mode, and adds a new error code for mutation attempts in read‐only transactions.

Reviewed Changes

Copilot reviewed 26 out of 26 changed files in this pull request and generated no comments.

Show a summary per file
File Description
core/src/main/java/com/scalar/db/transaction/singlecrudoperation/SingleCrudOperationTransactionManager.java Added read‐only methods that throw an UnsupportedOperationException.
core/src/main/java/com/scalar/db/transaction/jdbc/JdbcTransactionManager.java Updated begin and executeTransaction methods to support a readOnly parameter.
core/src/main/java/com/scalar/db/transaction/consensuscommit/TwoPhaseConsensusCommitManager.java Modified CrudHandler construction to include a readOnly flag.
core/src/main/java/com/scalar/db/transaction/consensuscommit/Snapshot.java Expanded inline documentation for transaction sets.
core/src/main/java/com/scalar/db/transaction/consensuscommit/CrudHandler.java Introduced conditional behavior based on a readOnly flag for handling read set and scan validation.
core/src/main/java/com/scalar/db/transaction/consensuscommit/ConsensusCommitManager.java Added read‐only transaction methods and wrapped transactions when in read‐only mode.
core/src/main/java/com/scalar/db/storage/jdbc/RdbEngineStrategy.java Renamed method to setConnectionToReadOnly and adjusted its signature.
core/src/main/java/com/scalar/db/storage/jdbc/JdbcDatabase.java Updated calls to use the renamed setConnectionToReadOnly method.
core/src/main/java/com/scalar/db/storage/jdbc/JdbcAdmin.java Updated methods to set JDBC connections to read‐only mode via the renamed method.
core/src/main/java/com/scalar/db/storage/dynamo/SelectStatementHandler.java Added documentation for the new fetchSize parameter.
core/src/main/java/com/scalar/db/service/TransactionService.java Exposed read‐only transaction methods that delegate to the underlying manager.
core/src/main/java/com/scalar/db/common/error/CoreError.java Introduced a new error code for mutations attempted in read‐only transactions.
core/src/main/java/com/scalar/db/common/ReadOnlyDistributedTransaction.java Provided a read‐only transaction proxy that forbids mutation operations.
core/src/main/java/com/scalar/db/common/DecoratedDistributedTransactionManager.java Forwarded read‐only transaction methods from the decorated manager.
core/src/main/java/com/scalar/db/api/DistributedTransactionManager.java Extended the interface to include read‐only transaction methods with appropriate Javadoc.
Comments suppressed due to low confidence (3)

core/src/main/java/com/scalar/db/transaction/singlecrudoperation/SingleCrudOperationTransactionManager.java:79

  • Consider adding a clarifying comment explaining why read-only transactions are not supported in this transaction manager, to aid future maintainers in understanding the design decision.
@Override

core/src/main/java/com/scalar/db/common/error/CoreError.java:934

  • Ensure that the new error code '0211' for MUTATION_NOT_ALLOWED_IN_READ_ONLY_TRANSACTION is documented in the project’s error handling guidelines for consistency.
MUTATION_NOT_ALLOWED_IN_READ_ONLY_TRANSACTION(

core/src/main/java/com/scalar/db/transaction/consensuscommit/ConsensusCommitManager.java:244

  • Since the CrudHandler is constructed with a readOnly flag and the transaction is further wrapped in a ReadOnlyDistributedTransaction, please verify that this double application is intentional and consider adding a comment to clarify the rationale.
if (readOnly) {

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!

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! 👍

@brfrn169 brfrn169 merged commit 88ccee8 into master Jun 11, 2025
55 checks passed
@brfrn169 brfrn169 deleted the support-begin-in-read-only-mode branch June 11, 2025 10:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants