Skip to main content

CheckpointConfig

Struct CheckpointConfig 

Source
pub struct CheckpointConfig {
    pub interval: Duration,
    pub warn_pages: u64,
    pub warn_sustained_cycles: u8,
    pub high_water_pages: u64,
    pub truncate_high_water_pages: u64,
    pub truncate_min_interval: Duration,
    pub truncate_busy_timeout: Duration,
    pub tx_warn_secs: Duration,
    pub tx_max_age_secs: Duration,
}
Expand description

Configuration for the WAL checkpoint background task.

All fields default to conservative production values. Override via the environment variables documented on each field.

Fields§

§interval: Duration

How often to run a passive checkpoint when there is no active write.

Overridable via KHIVE_CHECKPOINT_INTERVAL_MS (milliseconds). Default: 500 ms.

§warn_pages: u64

WAL page count above which a warning is logged.

Overridable via KHIVE_WAL_WARN_PAGES. Default: 2000 pages (~8 MB at 4 KiB page size).

§warn_sustained_cycles: u8

Number of consecutive observed ticks with wal_pages >= warn_pages required before the ADR-091 severity ladder escalates from INFO (first crossing) to WARN (sustained pressure). Edge-triggered once per elevation episode — see CheckpointSeverityState.

Overridable via KHIVE_WAL_WARN_SUSTAINED_CYCLES. Default: 3 cycles.

§high_water_pages: u64

WAL page count above which a high-pressure WARNING is logged.

The periodic task always runs PASSIVE regardless; this threshold signals that a long-lived reader may be pinning an old WAL snapshot that PASSIVE cannot reclaim. An operator can then schedule a blocking TRUNCATE at a safe moment outside normal write traffic.

Overridable via KHIVE_WAL_HIGH_WATER_PAGES. Default: 6000 pages (~24 MB at 4 KiB page size).

§truncate_high_water_pages: u64

WAL page count above which a TRUNCATE escalation attempt is armed (ADR-091 Plank 2).

This is a separate, much higher threshold than high_water_pages: crossing it does not itself attempt TRUNCATE — it only arms the attempt, which additionally requires truncate_min_interval to have elapsed since the last attempt.

Overridable via KHIVE_WAL_TRUNCATE_HIGH_WATER_PAGES. Default: 20000 pages.

§truncate_min_interval: Duration

Minimum spacing between TRUNCATE attempts (not successes).

A skipped tick (writer busy, below threshold, or interval not yet elapsed) never advances the “last attempt” clock, so the next tick where the writer is free and the threshold is still crossed is immediately eligible rather than waiting out the full interval again.

Overridable via KHIVE_WAL_TRUNCATE_MIN_INTERVAL_SECS. Default: 300 seconds (5 minutes).

§truncate_busy_timeout: Duration

Temporary busy_timeout used only for the duration of a TRUNCATE attempt, restored to the pool’s configured busy timeout immediately after the attempt completes (win or lose).

Overridable via KHIVE_WAL_TRUNCATE_BUSY_MS. Default: 2000 ms.

§tx_warn_secs: Duration

ADR-091 Plank 1 soft cap: age past which the oldest entry in the shared open-transaction registry is surfaced at tracing::warn! on every tick (Skipped or Observed), independent of WAL page pressure. See crates/khive-db/docs/api/checkpoint.md for the Plank 1 rationale.

Overridable via KHIVE_TX_WARN_SECS. Default: 30 seconds.

§tx_max_age_secs: Duration

ADR-091 Plank 1 hard cap: age past which the same sweep escalates the oldest registry entry to tracing::error!. This is visibility only — nothing here can force-close a stale span; see crates/khive-db/docs/design.md for why.

Overridable via KHIVE_TX_MAX_AGE_SECS. Default: 120 seconds.

Implementations§

Source§

impl CheckpointConfig

Source

pub fn from_env() -> CheckpointConfig

Build a CheckpointConfig from the environment.

Unset or unparseable variables fall back to the compiled-in defaults.

Trait Implementations§

Source§

impl Clone for CheckpointConfig

Source§

fn clone(&self) -> CheckpointConfig

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 CheckpointConfig

Source§

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

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

impl Default for CheckpointConfig

Source§

fn default() -> CheckpointConfig

Returns the “default value” for a type. 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> 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> FromRef<T> for T
where T: Clone,

Source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
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