quasar_postgres/reaper

Expired leases are recovered independently of demand/claim traffic.

Types

pub type Event {
  Reaped(rows: Int, duration_ms: Int)
  ReapFailed
}

Constructors

  • Reaped(rows: Int, duration_ms: Int)
  • ReapFailed
pub opaque type Runtime

Values

pub fn batch(
  connection: pog.Connection,
  now: Int,
  limit: Int,
) -> Result(Int, pog.QueryError)

One bounded statement. SKIP LOCKED makes concurrent replicas safe; the advisory lock avoids all replicas doing the same empty scan simultaneously. now is milliseconds since epoch, exposed for deterministic recovery tests.

pub fn start(
  connection: pog.Connection,
  interval_ms: Int,
  report: fn(Event) -> Nil,
) -> Result(Runtime, actor.StartError)

Start once per application, before Quasar, and stop before closing the pool. Batches are capped at 500; a full batch waits 100ms, otherwise interval_ms. Queries failing never stop subsequent recovery attempts. Reporters receive no database error payloads (which can contain connection credentials).

pub fn stop(runtime: Runtime) -> Result(Nil, Nil)
Search Document