@zeropg/lease
v0.0.1
Published
Early experiment in the cheapest possible scale-to-zero Postgres. Single-writer lease on object storage for zeropg: conditional-create acquire, CAS renew/takeover, monotonic fencing tokens. No coordination service, no clock dependence for correctness.
Maintainers
Readme
@zeropg/lease
A single-writer lease built entirely on object-storage conditional writes. No coordination service, no clock dependence for correctness.
acquire()— conditional create oflease.json; if held and unexpired →LockedError; if expired → CAS takeover with a strictly increasing fencing token (floored by the manifest, so tokens are monotonic across the bucket's whole history).renew()— CAS on our own version; failure means we were taken over →FencedError.validate()— cheap read-path check.release()— CAS- guarded delete so successors can acquire instantly.tookOvertells the caller a previous holder may still be alive (zeropg uses this to fence-stamp the manifest immediately).
Correctness comes from the conditional writes; the clock only tunes how aggressively expired leases are taken over. Validated live: 100/100 stale renewals rejected, 100/100 stale commits rejected, zero two-holder windows, plus a live two-service zombie test on Cloud Run (repo experiments E1, E4).
