-
Notifications
You must be signed in to change notification settings - Fork 40
Add support for beginning transactions in read-only mode #2749
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.
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) {
Torch3333
left a comment
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.
LGTM, thank you!
feeblefakie
left a comment
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.
LGTM! Thank you!
komamitsu
left a comment
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.
LGTM! 👍
Description
This PR adds support for beginning transactions in read-only mode. It simply merges the
support-begin-in-read-only-modefeature branch into themasterbranch, and the code has already been reviewed.Related issues and/or PRs
Changes made
support-begin-in-read-only-modefeature branch to themasterbranchChecklist
Additional notes (optional)
N/A
Release notes
Added support for beginning transactions in read-only mode.