Repository navigation
feat(storage): support single-shard transactions on the in-process Raft adapter - #407
Conversation
ashione
left a comment
There was a problem hiding this comment.
Two inline notes on the in-process transaction contract: admission on managed shards and coverage for a timeout before Raft handoff.
| let end = options.deadline.min(self.dispatch_deadline()?); | ||
| let sequence = self.dispatch_until(None, end, async move { | ||
| leader_barrier(&raft).await?; | ||
| checked_sequence(&state, shard, epoch).await |
There was a problem hiding this comment.
P2: Reject already-managed shards at begin_v1. This barrier and metadata read checks shard, epoch, and sequence, but not the write mode. A managed shard can therefore return a usable-looking handle and accept the entire staged batch, even though D1Command::Write will reject it with ManagedWriteRequired at commit. Could we check the mode in the same state read as the sequence and return Unsupported here? Keep the existing apply-time check for mode changes after begin.
| if let Err(error) = options.check() { | ||
| return Ok(Err(error)); | ||
| } | ||
| if submission.swap(true, Ordering::AcqRel) { |
There was a problem hiding this comment.
P2: Cover the timeout-before-handoff branch. The new paused-apply test covers UnknownOutcome after handoff. Please add a deterministic test for the other side of this race: gate the worker before it claims submission, let the caller deadline close the window, then release or drain the worker and verify that the shard sequence is unchanged and neither staged key exists. This would pin down the no-late-write guarantee; no failure is known on this path.
Summary
Refs #393. Implement the write-only single-shard transaction contract on the in-process Raft adapter. Begin captures the committed sequence after a leader read barrier. Commit sends one conditional D1V1 batch with the original epoch, sequence and request ID.
Contract and scope
Local and replicated adapters share the bounded staging buffer. A staging error discards the accepted prefix. Abort and drop discard all staged operations. Failed admission and sequence conflicts remain explicit. A timeout after Raft submission returns
UnknownOutcomewith the original request ID, and the caller does not automatically replay the batch. The existing log and storage formats are unchanged.Remote and routed transaction entry points, independent-process crash/restart coverage and recovery of the original commit outcome remain open in #393. The README, transaction contract, current status and roadmap describe the supported entry points. This PR adds no CLI or graph query syntax.
Verification
On PR head
cfeab68, with Rust 1.100.0 on macOS:cargo test --locked -p replicated-graph --test cluster staged_transactionpassed both new three-voter tests. After leader change the new leader sees the complete winning batch and no keys from rejected or aborted transactions. When state-machine application is paused after staging, commit can time out and the entire batch can subsequently appear once.cargo fmt --all --check,cargo clippy --all-targets --locked -- -D warningsandgit diff --check HEAD~2 HEADpassed.3bdf8fausedcargo test --locked --no-fail-fastand passed 1,445 tests across 98 targets, with 0 failures and 47 ignored. Local validation dynamically linked RocksDB from the locked build to limit disk usage. The rebase onto docs: align recovery, transaction and benchmark evidence with main #406 and the subsequent status update changed only documentation, verified by diffing the two revisions.