Skip to content

Replace PostgreSQL advisory locking with fenced leases - #1111

Draft
joostjager wants to merge 1 commit into
lightningdevkit:mainfrom
joostjager:postgres-leases
Draft

joostjager wants to merge 1 commit into
lightningdevkit:mainfrom
joostjager:postgres-leases

Conversation

@joostjager

Copy link
Copy Markdown
Contributor

Acquire a table-scoped lease before loading persisted state and validate and renew it atomically with each mutation. Renew idle leases in the background and permanently invalidate the store on detected lease loss, preserving panic behavior and the existing lock-contention error kind.

Coordinate the one-way schema-v1 upgrade with the legacy advisory lock and commit the schema-v2 marker with the initial lease. Older releases then reject the upgraded store instead of bypassing lease fencing.

Keep lease handling inside PostgresStore, with node lifecycle and recovery unchanged. Cover contention, migration, queued-write fencing, lease release, and panic propagation in the store tests.

Acquire a table-scoped lease before loading persisted state and validate
and renew it atomically with each mutation. Renew idle leases in the
background and permanently invalidate the store on detected lease loss,
preserving panic behavior and the existing lock-contention error kind.

Coordinate the one-way schema-v1 upgrade with the legacy advisory lock
and commit the schema-v2 marker with the initial lease. Older releases
then reject the upgraded store instead of bypassing lease fencing.

Keep lease handling inside PostgresStore, with node lifecycle and
recovery unchanged. Cover contention, migration, queued-write fencing,
lease release, and panic propagation in the store tests.
@ldk-reviews-bot

Copy link
Copy Markdown

👋 Hi! I see this is a draft PR.
I'll wait to assign reviewers until you mark it as ready for review.
Just convert it out of draft status when you're ready for review!

@tnull tnull left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs a rebase for CI to run. Let me know when fully ready for review.

@tnull tnull added this to the 0.8 milestone Sep 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants