#[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
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
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 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 ==.