Skip to content

Commit 20b2314

Browse files
authored
Merge ' core/mvcc: Implement Hekaton commit dependency tracking ' from Pere Diaz Bou
Fixes #5136: Implement the register-and-report commit dependency protocol from the Hekaton paper (Section 2.7) to fix partial commit visibility. During commit, row timestamps are converted from TxID to Timestamp one by one while the transaction is in Preparing state. Without dependency tracking, concurrent readers could see partial commits — some rows visible (already converted to Timestamp) and others not (still TxID pointing to a Preparing tx), violating snapshot isolation. The fix changes is_begin_visible to speculatively read from Preparing transactions when begin_ts >= end_ts, and registers a commit dependency via the Hekaton protocol: - CommitDepCounter (AtomicU64): counts unresolved dependencies; must reach zero before a transaction can commit. - AbortNow (AtomicBool): set by a depended-on transaction on abort to cascade the abort to dependents. - CommitDepSet (Mutex<Vec<TxID>>): stores IDs of transactions that depend on this one; drained during commit/abort postprocessing. New WaitForDependencies commit state sits between validation and timestamp postprocessing, yielding until all dependencies resolve. <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **High Risk** > Touches core MVCC visibility/commit state machine and adds cross- transaction dependency tracking with new waiting/abort behavior, which is concurrency-sensitive and could introduce subtle correctness or liveness regressions. > > **Overview** > Fixes partial-commit visibility under snapshot isolation by implementing Hekaton §2.7 commit dependencies: transactions can now *speculatively* read/ignore versions from `Preparing` transactions and register a dependency via `commit_dep_counter`, `abort_now`, and `commit_dep_set`. > > The commit state machine adds `WaitForDependencies` between validation and timestamp postprocessing, yielding until dependencies resolve, and cascades aborts/notifications by draining `commit_dep_set` on commit/rollback (with a new `LimboError::CommitDependencyAborted`). Extensive new tests cover speculative read/ignore, cascade abort, read- only edge cases, and a regression reproducer for the prior partial- visibility bug. > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit 22c0deb. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY --> Closes #5328
2 parents cb7b0bd + 9639fd6 commit 20b2314

File tree

3 files changed

+1310
-41
lines changed

3 files changed

+1310
-41
lines changed

core/error.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@ pub enum LimboError {
7979
TxTerminated,
8080
#[error("Write-write conflict")]
8181
WriteWriteConflict,
82+
#[error("Commit dependency aborted")]
83+
CommitDependencyAborted,
8284
#[error("No such transaction ID: {0}")]
8385
NoSuchTransactionID(String),
8486
#[error("Null value")]

0 commit comments

Comments
 (0)