Skip to content

Add tx_write_set column to the Coordinator table#3558

Open
brfrn169 wants to merge 1 commit into
masterfrom
add-tx-write-set-column-to-coordinator-table
Open

Add tx_write_set column to the Coordinator table#3558
brfrn169 wants to merge 1 commit into
masterfrom
add-tx-write-set-column-to-coordinator-table

Conversation

@brfrn169
Copy link
Copy Markdown
Collaborator

@brfrn169 brfrn169 commented May 7, 2026

Description

This PR adds a new tx_write_set (BLOB) column to the Coordinator table schema. The column is the first piece of an upcoming feature that records the write set of each transaction in the Coordinator table, which will enable proactive recovery of orphan PREPARED records (rather than relying solely on per-record lazy recovery) and lay the groundwork for future backup-based recovery.

The column is added unconditionally on the master branch. Existing Coordinator tables created with earlier versions are migrated automatically by Admin.upgrade(), which detects the missing column and adds it via ALTER TABLE. The runtime logic that populates the column will be added in a follow-up PR.

Related issues and/or PRs

N/A

Changes made

  • Added Attribute.WRITE_SET = "tx_write_set" constant.
  • Added the tx_write_set (BLOB) column to Coordinator.TABLE_METADATA.
  • Included Attribute.WRITE_SET in ConsensusCommitAdmin.upgradeCoordinatorTable()'s potentialMissingColumnNames so existing tables receive the column during Admin.upgrade().
  • Updated the unit test in ConsensusCommitAdminTestBase to verify that both tx_child_ids and tx_write_set are added when missing (test method renamed to upgrade_CoordinatorTableExistsButMissingChildIdsAndWriteSetColumns_ShouldAddMissingColumns).
  • Updated the comment in SchemaLoaderIntegrationTestBase.upgrade_WithOldCoordinatorTableSchema_ShouldProperlyUpdateTheSchema to reflect that both columns are part of the upgrade migration.

Checklist

  • 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)

The follow-up PR will add the proto definitions and the runtime logic that populates the new column on commit/abort.

Release notes

Added a tx_write_set column to the Coordinator table to lay the groundwork for proactive transaction recovery. The column is added automatically to existing Coordinator tables when Admin.upgrade() is run.

This is the first step toward recording the write set of each transaction
in the Coordinator table, which will be used for proactive recovery of
PREPARED records and future backup-based recovery use cases.

The runtime logic that populates the column will be added in a follow-up PR.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown
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 introduces a tx_write_set column to the coordinator table for the consensus commit transaction manager. The changes include updating the Attribute class, table metadata, and upgrade logic, with corresponding test updates. Feedback suggests moving the new column to the end of the metadata definition to maintain consistent column ordering across fresh and upgraded installations.

@brfrn169 brfrn169 self-assigned this May 7, 2026
@brfrn169 brfrn169 added the enhancement New feature or request label May 7, 2026
Copilot AI review requested due to automatic review settings May 7, 2026 06:26
Copy link
Copy Markdown
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 extends the Consensus Commit coordinator table schema by adding a new tx_write_set column (BLOB) and updates the upgrade path so existing coordinator tables are automatically migrated via Admin.upgrade().

Changes:

  • Added Attribute.WRITE_SET ("tx_write_set") and included it in Coordinator.TABLE_METADATA as a BLOB column.
  • Updated ConsensusCommitAdmin.upgradeCoordinatorTable() to detect and add the missing tx_write_set column (alongside tx_child_ids) during upgrades.
  • Updated unit/integration tests to validate the upgrade behavior when both columns are missing.

Reviewed changes

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

Show a summary per file
File Description
integration-test/src/main/java/com/scalar/db/schemaloader/SchemaLoaderIntegrationTestBase.java Updates the old-schema test comment to reflect both missing columns for upgrade coverage.
core/src/test/java/com/scalar/db/transaction/consensuscommit/ConsensusCommitAdminTestBase.java Renames/extends the upgrade test to verify both tx_child_ids and tx_write_set columns are added.
core/src/main/java/com/scalar/db/transaction/consensuscommit/Coordinator.java Adds tx_write_set (BLOB) to the coordinator table metadata.
core/src/main/java/com/scalar/db/transaction/consensuscommit/ConsensusCommitAdmin.java Extends coordinator-table upgrade logic to include the new column.
core/src/main/java/com/scalar/db/transaction/consensuscommit/Attribute.java Introduces the WRITE_SET attribute constant.

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

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.

2 participants