Commit 20b2314
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 #53283 files changed
+1310
-41
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
79 | 79 | | |
80 | 80 | | |
81 | 81 | | |
| 82 | + | |
| 83 | + | |
82 | 84 | | |
83 | 85 | | |
84 | 86 | | |
| |||
0 commit comments