pub struct WriteCoordinator { /* private fields */ }Expand description
The WriteCoordinator serializes the validation + commit_seq allocation +
marker append section of the native commit protocol (§7.11.2).
The serialized section (steps 2-8) MUST NOT observe cancellation once
commit_seq is allocated. The coordinator MUST NOT write page payloads
in the serialized section — only marker + proof.
Implementations§
Source§impl WriteCoordinator
impl WriteCoordinator
Sourcepub fn new(
mode: OperatingMode,
initial_seq: CommitSeq,
group_commit_max: usize,
) -> Self
pub fn new( mode: OperatingMode, initial_seq: CommitSeq, group_commit_max: usize, ) -> Self
Create a new coordinator for the given mode.
initial_seq is the highest committed sequence from recovery.
group_commit_max is the maximum batch size for group commit.
Sourcepub const fn mode(&self) -> OperatingMode
pub const fn mode(&self) -> OperatingMode
The current operating mode.
Sourcepub const fn commit_seq_tip(&self) -> CommitSeq
pub const fn commit_seq_tip(&self) -> CommitSeq
The current commit sequence tip (highest committed).
Sourcepub fn pending_count(&self) -> usize
pub fn pending_count(&self) -> usize
Number of pending commits in the current group batch.
Sourcepub const fn current_epoch(&self) -> u64
pub const fn current_epoch(&self) -> u64
The current epoch (incremented once per group commit flush).
Sourcepub fn initiate_shutdown(&mut self)
pub fn initiate_shutdown(&mut self)
Initiate shutdown: new submissions will be rejected.
Sourcepub fn validate(
&self,
submission: &CommitSubmission,
) -> Result<(), CommitResult>
pub fn validate( &self, submission: &CommitSubmission, ) -> Result<(), CommitResult>
Step 1: Validate a submission (FCW + SSI re-validation).
Returns Ok(()) if validation passes, or Err(CommitResult) with
the rejection reason.
The coordinator MUST NOT decode the entire capsule here — only check the write-set summary against the commit index.
Sourcepub fn submit(
&mut self,
submission: CommitSubmission,
now_unix_ns: u64,
) -> Result<CommitSeq, CommitResult>
pub fn submit( &mut self, submission: CommitSubmission, now_unix_ns: u64, ) -> Result<CommitSeq, CommitResult>
Steps 2-8: Process a validated submission through the serialized section.
This allocates a commit_seq, builds the proof and marker, and adds the commit to the group batch. Returns the allocated commit result.
The caller MUST call flush_batch to actually issue fsyncs and
complete the commits.
§Errors
Returns Err if validation fails (FCW or SSI conflict).
Sourcepub fn fsync1(&mut self) -> usize
pub fn fsync1(&mut self) -> usize
Execute FSYNC_1 (pre-marker group commit point).
Makes all pending capsule symbols AND CommitProof objects durable BEFORE markers reference them. Without this barrier, NVMe write reordering can make a marker durable while referents are not.
Returns the number of commits covered by this fsync.
Sourcepub fn append_markers_and_fsync2(&mut self) -> Vec<CommitMarker>
pub fn append_markers_and_fsync2(&mut self) -> Vec<CommitMarker>
Steps 5-6: Append markers and execute FSYNC_2 (post-marker).
For each pending commit with FSYNC_1 complete, appends a
CommitMarker to the marker stream, then marks FSYNC_2 complete.
Returns the markers that were appended.
Sourcepub fn drain_committed(&mut self) -> Vec<CommitResult>
pub fn drain_committed(&mut self) -> Vec<CommitResult>
Steps 7-8: Drain committed entries and return results.
Step 7 (SHM publish) is the caller’s responsibility after receiving these results — the coordinator only manages the serialized section.
Sourcepub fn flush_batch(&mut self) -> Vec<CommitResult>
pub fn flush_batch(&mut self) -> Vec<CommitResult>
Flush the pending batch: fsync1, append markers, fsync2, drain.
Wraps the full group commit cycle in a parallel_wal_commit tracing
span with epoch, group_size, and commit_seq range fields.
Returns the committed results and records metrics.
Sourcepub fn submit_and_commit(
&mut self,
submission: CommitSubmission,
now_unix_ns: u64,
) -> CommitResult
pub fn submit_and_commit( &mut self, submission: CommitSubmission, now_unix_ns: u64, ) -> CommitResult
Convenience: submit, fsync1, append markers, fsync2, drain.
Processes a single submission through the entire protocol. In production, submissions are batched; this is for testing and single-commit workloads.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for WriteCoordinator
impl RefUnwindSafe for WriteCoordinator
impl Send for WriteCoordinator
impl Sync for WriteCoordinator
impl Unpin for WriteCoordinator
impl UnsafeUnpin for WriteCoordinator
impl UnwindSafe for WriteCoordinator
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, _span: NoopSpan) -> Self
fn instrument(self, _span: NoopSpan) -> Self
Source§fn in_current_span(self) -> Self
fn in_current_span(self) -> Self
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more