Skip to content

Conversation

@brfrn169
Copy link
Collaborator

@brfrn169 brfrn169 commented Jun 18, 2025

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

  • Updated CommitMutationComposer and RollbackMutationComposer to set the before image columns to null.

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

Updated the code to remove before images after committing or rolling back records in Consensus Commit to reduce disk usage.

@brfrn169 brfrn169 requested a review from Copilot June 18, 2025 05:14
@brfrn169 brfrn169 self-assigned this Jun 18, 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 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";

@brfrn169 brfrn169 force-pushed the remove-before-images-after-commit-or-rollback branch from 82348f2 to 3207eaa Compare June 18, 2025 05:18
Comment on lines +105 to +113
// 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);
}
Copy link
Collaborator Author

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.

Comment on lines +121 to +122
// Set before image columns to null
setBeforeImageColumnsToNull(putBuilder, beforeImageColumnNames, tableMetadata);
Copy link
Collaborator Author

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.

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 044443f into master Jun 18, 2025
56 checks passed
@brfrn169 brfrn169 deleted the remove-before-images-after-commit-or-rollback branch June 18, 2025 13:34
feeblefakie pushed a commit that referenced this pull request Jun 18, 2025
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.

3 participants