Delivery / Engineering notes
A lease needs a fence
Why an expired lease is not enough to stop a stale worker from writing.
The worker that comes back
A worker takes a delivery, sends it, then stalls before recording what happened. Its lease expires and another worker takes the row. When the first one wakes up, the question is not whether it once owned that delivery. It is whether it owns the current attempt.
Check ownership when the write happens
RelayForge issues a fresh fencing token on each claim. Finalisation checks the token and the in-flight state in the database. The late worker can no longer overwrite a newer result. A worker ID could not make that distinction: the same process can hold the same delivery twice.
This does not unsend an HTTP request
The fence protects the database write, not the receiver. A request can succeed just before the worker crashes, and the next attempt can send it again. That is why the delivery contract is at-least-once and why the receiver gets an idempotency key.