Skip to main content

CheckpointPolicy

Enum CheckpointPolicy 

Source
#[non_exhaustive]
pub enum CheckpointPolicy { Flush, Fsync, FsyncEveryN(u32), }
Expand description

Persistence policy a CheckpointSink requests from the apply driver.

After a checkpoint is recorded, the apply driver inspects this value to decide how aggressively to push pending writes through the operating system. Cheap sinks (in-memory test capture) ask for Self::Flush; durability-sensitive sinks (persist-to-disk so a crash recovers cleanly) ask for Self::Fsync or Self::FsyncEveryN.

The driver calls crate::ApplyContext::sync_all when the policy demands it, which both flushes every cached BufWriter and calls File::sync_all on the underlying handle. Honouring this on every record would gut throughput on patches with millions of regions — hence Self::FsyncEveryN for the typical “fsync every N records” cadence downstream consumers want.

Mid-block checkpoints — the per-DEFLATE-block emissions inside crate::chunk::sqpk::SqpkFile AddFile — never flush and never fsync regardless of policy. Those emissions fire often enough on a multi-GB file that interleaving a sync syscall would gut throughput. The driver guarantees the next chunk-boundary checkpoint flushes the bytes the mid-block run accumulated in its BufWriter, so a resume from an in-flight checkpoint can never miss data that a later chunk-boundary checkpoint already covered.

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

Flush

Flush BufWriter buffers to the OS only; no fsync. Survives a process crash but not an OS crash or power loss between checkpoint and recovery.

§

Fsync

Flush and fsync every cached file handle on every recorded checkpoint. Strongest durability; pay the syscall cost on every record.

§

FsyncEveryN(u32)

Flush every record; fsync once every N records. N == 0 is rejected at sink-installation time (crate::ApplyContext::with_checkpoint_sink and crate::IndexApplier::with_checkpoint_sink both panic) — use Self::Fsync for “fsync every record” instead.

In-flight mid-block checkpoints (the per-DEFLATE-block emissions inside crate::chunk::sqpk::SqpkFile AddFile) never fsync regardless of policy: those emissions are too frequent to interleave with a sync syscall, and the apply driver guarantees that a resume from an in-flight checkpoint can never miss data that a later chunk-boundary checkpoint already covered.

Trait Implementations§

Source§

impl Clone for CheckpointPolicy

Source§

fn clone(&self) -> CheckpointPolicy

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for CheckpointPolicy

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Hash for CheckpointPolicy

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for CheckpointPolicy

Source§

fn eq(&self, other: &CheckpointPolicy) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Copy for CheckpointPolicy

Source§

impl Eq for CheckpointPolicy

Source§

impl StructuralPartialEq for CheckpointPolicy

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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: 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> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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<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