| Crates.io | pg_lease |
| lib.rs | pg_lease |
| version | 0.1.3 |
| created_at | 2025-06-22 16:15:04.798307+00 |
| updated_at | 2025-06-22 18:51:27.685916+00 |
| description | Postgres lease management package for running a single looping function while a lease is held |
| homepage | |
| repository | https://github.com/danthegoodman1/pg_lease |
| max_upload_size | |
| id | 1721730 |
| size | 89,683 |
Go and Rust package for Postgres lease management package for running a single looping function while a lease is held.
This is a great building block for distributed systems that need a simple mechanism to coordinate ownership of partitions via a single process making decisions. This can then be integrated with VerifyLeaseHeld to transactionally verify that the lease is still held when making updates.
Downstream dependencies (e.g. partitions) would asynchornously receive updates and use transactional methods to verify they own the partition when doing some operation (e.g. writing log segment metadata to postgres as the metadata store).
With the current design, if a worker dies and then restarts, it can actually recover its lease before the timeout!
While this could be use to optimize for recovery, I chose not to use it for 2 reasons: