SQLStreams

the messaging platform that is just Postgres

You last visited on 9999-99-99 Show what's new since then

0047 — Delivery is at-least-once; consumerFunc must be idempotent

Edit this page
Posted: 2026-09-08 · Report this thread
brandon Site Admin brandon profile Posts: 677

Context. Lease reclamation means the same message can be processed twice: a worker that runs past its lease looks crashed and gets reclaimed, and a worker that crashes after its side effect but before RecordSuccess re-runs regardless of lease length. This was demonstrated deliberately (a sleep longer than the lease produced a double-processing).

Decision. At-least-once is the stated contract. consumerFunc is documented as “ideally idempotent func”, and the lease window is kept comfortably longer than the work timeout so live workers are rarely reclaimed.

Consequences. Idempotency is mandatory for correctness — a longer lease only lowers how often double-delivery happens and can never eliminate it. The two mitigations are complementary, not alternatives: the timeout buffer controls frequency, idempotency makes the residual deliveries harmless.