pub async fn run_checkpoint_task(
pool: Arc<ConnectionPool>,
config: CheckpointConfig,
event_store: Option<Arc<dyn EventStore>>,
namespace: String,
shutdown_rx: Receiver<()>,
)Expand description
Run the WAL checkpoint background task.
Long-running async task — spawn with tokio::spawn. Loops until
shutdown_rx observes a change (or its sender is dropped). Callers MUST
hold the paired tokio::sync::watch::Sender for the daemon’s run scope
and send on it to shut down — do NOT rely on pool’s Arc refcount
reaching zero; a sibling owner (e.g. event_store) holding its own clone
makes that check unreachable (issue #774).
Issues PRAGMA wal_checkpoint(PASSIVE) every tick via try_writer_nowait
(zero-wait try-lock): a busy writer skips the tick rather than stalling
write traffic. A WARNING fires once per below→above threshold crossing,
not every tick.
event_store (ADR-094): when Some, appends a best-effort
CheckpointOutcomeRecorded event on every at/above-warn_pages tick,
plus one drain row when pressure falls back below warn_pages. None is
a no-op. See crates/khive-db/docs/api/checkpoint.md for the full
shutdown-mechanism and event-emission design history.