Background leader lock

The idea

Only the process that holds a Postgres advisory lock runs background work. Other processes serve requests as warm standbys.

The problem
Two processes share the database during a release switch and could run the same jobs twice.
Why it matters
Release switches and rollbacks run without double work, and a drained process can take over in about a second.
Where it stands
In production as of

A step-by-step replay of this idea is not published yet. The library adds one when a recorded run shows it.

  • Postgres job queue with dead letters

    Background work is stored as job rows, claimed with leases and heartbeats, and retried with backoff. A job that keeps failing stays as a dead letter for 30 days.

  • Gated release with append-only migrations

    One script builds the committed head, migrates in a throwaway container, swaps the image, checks health gates and rolls back on failure. Released migrations never change.

Turn the numbers into shipped work.

Crewshal runs these choices for you: a persistent AI worker with memory and rules, on your Claude and Codex subscriptions.