Skip to main content

WriteCoordinator

Struct WriteCoordinator 

Source
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

Source

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.

Source

pub const fn mode(&self) -> OperatingMode

The current operating mode.

Source

pub const fn commit_seq_tip(&self) -> CommitSeq

The current commit sequence tip (highest committed).

Source

pub fn pending_count(&self) -> usize

Number of pending commits in the current group batch.

Source

pub const fn current_epoch(&self) -> u64

The current epoch (incremented once per group commit flush).

Source

pub fn initiate_shutdown(&mut self)

Initiate shutdown: new submissions will be rejected.

Source

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.

Source

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).

Source

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.

Source

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.

Source

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.

Source

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.

Source

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§

Source§

impl Debug for WriteCoordinator

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, _span: NoopSpan) -> Self

Instruments this future with a span (no-op when disabled).
Source§

fn in_current_span(self) -> Self

Instruments this future with the current span (no-op when disabled).
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more