Skip to main content

checkpoint_once

Function checkpoint_once 

Source
pub fn checkpoint_once(
    pool: &ConnectionPool,
    config: &CheckpointConfig,
    truncate_state: &mut TruncateState,
) -> CheckpointTick
Expand description

Issue one checkpoint cycle against the writer connection.

Returns CheckpointTick::Skipped when the writer mutex is already held (the tick is a no-op) and CheckpointTick::Observed with the WAL page count otherwise. All checkpoint errors are logged at warn level and treated as non-fatal; the next tick retries.

Uses try_writer_nowait so that a busy active writer causes this tick to be skipped immediately rather than stalling for up to checkout_timeout. The caller (run_checkpoint_task) owns all threshold-crossing WARN logging so that warnings fire at most once per crossing, not every tick.

ADR-091 Plank 2: after the PASSIVE pass, this is also the single point that may escalate to TRUNCATE (maybe_truncate) — under the SAME writer guard acquired above, never a second checkout. A busy writer (Skipped) short-circuits before either PASSIVE or TRUNCATE run.