-
Notifications
You must be signed in to change notification settings - Fork 40
Remove before images after committing or rolling back records in Consensus Commit #2787
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
Remove before images after committing or rolling back records in Consensus Commit #2787
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 removes before images after committing or rolling back records in Consensus Commit to reduce disk usage. Key changes include:
- Updating tests to use a builder pattern and additional before image columns.
- Refactoring both CommitMutationComposer and RollbackMutationComposer to set before image columns to null via a new helper method.
- Introducing a new static helper method in AbstractMutationComposer for setting null values for before image columns.
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| core/src/test/java/com/scalar/db/transaction/consensuscommit/CommitMutationComposerTest.java | Updated test cases and expected mutations using the new builder pattern and additional before image columns. |
| core/src/main/java/com/scalar/db/transaction/consensuscommit/RollbackMutationComposer.java | Refactored mutation composition to use the new helper method and variables for retrieving table metadata. |
| core/src/main/java/com/scalar/db/transaction/consensuscommit/CommitMutationComposer.java | Updated commit mutation creation with the new builder pattern and before image column null-setting. |
| core/src/main/java/com/scalar/db/transaction/consensuscommit/AbstractMutationComposer.java | Added a new static helper to set null for before image columns based on data types. |
Comments suppressed due to low confidence (2)
core/src/main/java/com/scalar/db/transaction/consensuscommit/AbstractMutationComposer.java:45
- [nitpick] Consider adding JavaDoc comments for the setNullToBeforeImageColumns method to describe its purpose, behavior, and parameters, which would help maintainability and clarity.
TableMetadata tableMetadata) {
core/src/test/java/com/scalar/db/transaction/consensuscommit/CommitMutationComposerTest.java:54
- [nitpick] Test constants like ANY_NAME_4 through ANY_NAME_13 might be made more descriptive to indicate their correspondence to specific before image columns, improving test readability.
private static final String ANY_NAME_4 = "name4";
82348f2 to
3207eaa
Compare
| // Set before image columns to null | ||
| if (result != null) { | ||
| TransactionTableMetadata transactionTableMetadata = | ||
| tableMetadataManager.getTransactionTableMetadata(base); | ||
| LinkedHashSet<String> beforeImageColumnNames = | ||
| transactionTableMetadata.getBeforeImageColumnNames(); | ||
| TableMetadata tableMetadata = transactionTableMetadata.getTableMetadata(); | ||
| setBeforeImageColumnsToNull(putBuilder, beforeImageColumnNames, tableMetadata); | ||
| } |
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.
Added logic to set the before image columns to null.
| // Set before image columns to null | ||
| setBeforeImageColumnsToNull(putBuilder, beforeImageColumnNames, tableMetadata); |
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.
Ditto. Added logic to set the before image columns to null.
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 updates the code to remove before images after committing or rolling back records in Consensus Commit to reduce disk usage.
Related issues and/or PRs
N/A
Changes made
CommitMutationComposerandRollbackMutationComposerto set the before image columns to null.Checklist
Additional notes (optional)
N/A
Release notes
Updated the code to remove before images after committing or rolling back records in Consensus Commit to reduce disk usage.