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 ApplySession::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§
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::ApplyConfig::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
impl Clone for CheckpointPolicy
Source§fn clone(&self) -> CheckpointPolicy
fn clone(&self) -> CheckpointPolicy
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for CheckpointPolicy
impl Debug for CheckpointPolicy
Source§impl<'de> Deserialize<'de> for CheckpointPolicy
impl<'de> Deserialize<'de> for CheckpointPolicy
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl Hash for CheckpointPolicy
impl Hash for CheckpointPolicy
Source§impl PartialEq for CheckpointPolicy
impl PartialEq for CheckpointPolicy
Source§fn eq(&self, other: &CheckpointPolicy) -> bool
fn eq(&self, other: &CheckpointPolicy) -> bool
self and other values to be equal, and is used by ==.Source§impl Serialize for CheckpointPolicy
impl Serialize for CheckpointPolicy
impl Copy for CheckpointPolicy
impl Eq for CheckpointPolicy
impl StructuralPartialEq for CheckpointPolicy
Auto Trait Implementations§
impl Freeze for CheckpointPolicy
impl RefUnwindSafe for CheckpointPolicy
impl Send for CheckpointPolicy
impl Sync for CheckpointPolicy
impl Unpin for CheckpointPolicy
impl UnsafeUnpin for CheckpointPolicy
impl UnwindSafe for CheckpointPolicy
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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