Add tx_write_set column to the Coordinator table#3558
Conversation
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>
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 inCoordinator.TABLE_METADATAas a BLOB column. - Updated
ConsensusCommitAdmin.upgradeCoordinatorTable()to detect and add the missingtx_write_setcolumn (alongsidetx_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.
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 viaALTER 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
Attribute.WRITE_SET = "tx_write_set"constant.tx_write_set(BLOB) column toCoordinator.TABLE_METADATA.Attribute.WRITE_SETinConsensusCommitAdmin.upgradeCoordinatorTable()'spotentialMissingColumnNamesso existing tables receive the column duringAdmin.upgrade().ConsensusCommitAdminTestBaseto verify that bothtx_child_idsandtx_write_setare added when missing (test method renamed toupgrade_CoordinatorTableExistsButMissingChildIdsAndWriteSetColumns_ShouldAddMissingColumns).SchemaLoaderIntegrationTestBase.upgrade_WithOldCoordinatorTableSchema_ShouldProperlyUpdateTheSchemato reflect that both columns are part of the upgrade migration.Checklist
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_setcolumn to the Coordinator table to lay the groundwork for proactive transaction recovery. The column is added automatically to existing Coordinator tables whenAdmin.upgrade()is run.