Skip to content

Add PostgreSQL node failover leases#1000

Open
joostjager wants to merge 1 commit into
lightningdevkit:mainfrom
joostjager:postgres-node-failover
Open

Add PostgreSQL node failover leases#1000
joostjager wants to merge 1 commit into
lightningdevkit:mainfrom
joostjager:postgres-node-failover

Conversation

@joostjager

Copy link
Copy Markdown
Contributor

Addresses #932 by adding minimal active/passive failover support for nodes using the built-in PostgreSQL store.

PostgresStore acquires an exclusive lease for its KV table, renews it in the background, and fences every mutation by validating and renewing the lease in the same transaction. Lease loss is terminal for the node and is exposed to the application (ldk-server) so the process can exit and restart from persisted state.

This initial implementation is intentionally limited to PostgreSQL. Generic stores and VSS are out of scope. The API, timing configuration, and backend support can be extended later if operational experience requires it.

@joostjager
joostjager requested a review from tnull July 22, 2026 14:14
@ldk-reviews-bot

ldk-reviews-bot commented Jul 22, 2026

Copy link
Copy Markdown

👋 Thanks for assigning @tnull as a reviewer!
I'll wait for their review and will help manage the review process.
Once they submit their review, I'll check if a second reviewer would be helpful.

@joostjager

joostjager commented Jul 22, 2026

Copy link
Copy Markdown
Contributor Author

I’m primarily looking for a concept ACK on the overall direction at this stage. The code has already gone through several iterations, and it will probably need another pass once we agree that the lease, fencing, and process-exit approach is the right path.

ldk-server branch I've been testing with: lightningdevkit/ldk-server@main...joostjager:ldk-server:postgres-node-failover

Make PostgresStore acquire a table-scoped lease during construction
and fence every mutation with it. Treat runtime lease loss as
process-fatal so servers can exit without final persistence and
restart from durable state.
@joostjager
joostjager force-pushed the postgres-node-failover branch from 629386d to 056be7a Compare July 22, 2026 14:17
@benthecarman

Copy link
Copy Markdown
Contributor

Would be nice if this is abstracted out to also work with VSS. That way multi-device with a VSS backend can work

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