Repository navigation
multi: bump loop+pool to lnd conn-ownership fix, document ownership model - #1459
Closed
litbot-9000 wants to merge 3 commits into
Closed
litbot-9000 wants to merge 3 commits into
litbot-9000 wants to merge 3 commits into
Conversation
added 3 commits
October 30, 2026 22:54
Add an authoritative reference page for the connection-ownership relationship between litd and its integrated sub-servers: litd creates and owns the single shared *lndclient.GrpcLndServices and closes it exactly once in shutdownSubServers; integrated sub-servers receive a borrowed, non-closable view via StartAsSubserver and must never close it. Includes mermaid diagrams of the ownership relationship and the connection lifecycle, the failure mode behind the remote-lnd report in lightninglabs#1381 (comment 6530026672), and the verification layers (type-level prevention, regression tests, static guards) that keep this bug class from silently recurring. Refs lightninglabs#1381 (comment 6530026672). Refs lightninglabs#1329 (comment 6530856512).
Pin loop and pool to the connection-ownership fix from loop#1272 and pool#528, backported onto the currently pinned v0.35.2-beta and v0.7.2-beta releases. The replace directives are to be swapped for tagged releases before merge. The fix makes StartAsSubserver take the non-closable *lndclient.LndServices view instead of the closable *lndclient.GrpcLndServices wrapper, so an integrated Loop or Pool can no longer close LiT's shared lnd connection when it stops. Update both call sites to hand over the borrowed view; LiT remains the sole owner and closes the connection once in shutdownSubServers.
litbot-9000
force-pushed
the
deps/loop-pool-conn-ownership
branch
from
October 30, 2026 22:55
302818d to
a8e8f52
Compare
Author
|
Folded into #1458. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Refs #1381: fixes pinheadmz's remote-mode case, where every component dies within ms with
grpc: the client connection is closingwhile lnd is healthy. It does not address the OP's integrated-mode 30sDeadlineExceeded, which is a separate bug, so the issue should stay open.What
Integrated Loop and Pool closed LiT's shared
*lndclient.GrpcLndServiceswhenever they stopped, gracefully or because of a runtime error. That tore down the connection every other component depends on: the macaroon service, tapd, faraday and accounts. The fix is in the sub-servers:Both PRs make the borrowed connection non-closable by type.
StartAsSubservernow takes*lndclient.LndServices, which has noClose, instead of the closable wrapper. This is an intentional breaking API change. This PR is the litd side:replacedirectives, so litd builds and CI runs against it now.subservers/loop.goandsubservers/pool.gopass&lndGrpc.LndServices.docs/subserver-connection-ownership.mdwith the ownership model, the lifecycle and the rules (supersedes multi: bump loop+pool to lnd conn-ownership fix, document ownership model #1458), plus a newrelease-notes-0.17.11.mdbecause v0.17.10 is already tagged.litd itself needs no ownership change. It already closes the shared connection exactly once, in
shutdownSubServers, aftersubServerMgr.Stop(). Faraday and tapd are untouched: Faraday already haslndOwned, and tapd never receives the wrapper.Why
replaceto backport branches (not the PR heads)Pool master has already migrated to btcd v2 modules (lightninglabs/pool#524), and litd hasn't. Pinning pool master pulls in btcd v0.26.0, and
go mod tidythen fails on litd's ownbtcd/{chaincfg,wire,txscript}imports. To keep this PR to the fix, I cherry-picked the two fix commits from each PR onto the release tags litd already pins. Nothing else changed apart from dropping release-note hunks that didn't apply:v0.35.2-betalitbot-9000/loop@fix/lnd-conn-ownership-v0.35.2d72d75fb1ca1v0.7.2-betalitbot-9000/pool@fix/lnd-conn-ownership-v0.7.25b777bbd9744The ownership tests (
-run Ownership) pass on both backports. Before merge: cutloop v0.35.3-betaandpool v0.7.3-beta(or equivalent) from these branches, then swap thereplacelines for normalrequirebumps. Draft until then.Ownership model
flowchart TD subgraph LIT["lightning-terminal (litd) — OWNER"] CREATE["setupFullLNDClient()<br/>creates the single shared<br/><b>*lndclient.GrpcLndServices</b><br/>(closable wrapper)"] SHUTDOWN["shutdownSubServers()<br/>stops all sub-servers first,<br/>then closes the shared conn<br/><b>exactly once</b>"] end subgraph SUBSERVERS["integrated sub-servers — BORROWERS"] FARADAY["Faraday<br/>reference model:<br/>lndOwned tracking"] LOOP["Loop<br/>StartAsSubserver(<br/>*lndclient.LndServices)"] POOL["Pool<br/>StartAsSubserver(<br/>*lndclient.LndServices)"] TAPD["tapd<br/>never receives the wrapper"] end LND[("remote or integrated lnd")] CREATE -- "gRPC conn + subserver clients" --> LND CREATE -- "borrowed non-closable view<br/>(*lndclient.LndServices)" --> LOOP CREATE -- "borrowed non-closable view" --> POOL CREATE -- "borrowed view<br/>(lndOwned=false)" --> FARADAY CREATE -- "services only" --> TAPD LOOP -. "must never close<br/>(type-level: no Close in scope)" .-> LND POOL -. "must never close<br/>(type-level: no Close in scope)" .-> LND SHUTDOWN -- "the ONLY Close()<br/>on the shared conn" --> LNDstateDiagram-v2 [*] --> ConnAlive: litd creates shared GrpcLndServices ConnAlive --> SubserversRunning: litd injects borrowed view<br/>via StartAsSubserver SubserversRunning --> SubserverStopped: a sub-server stops<br/>(graceful or runtime error) SubserverStopped --> SubserversRunning: other sub-servers keep<br/>using the SAME conn SubserversRunning --> ConnClosed: litd shutdownSubServers()<br/>after ALL sub-servers stopped ConnClosed --> [*]Invariant: a sub-server stopping must not close the shared connection. Before the fix, loop and pool violated it.
Verification
go build -tags="litd_no_ui $(LND_RELEASE_TAGS)" ./...passes,go vet ./subservers/passes, andgo test ./subservers/passes..Close()of a borrowed handle.StartAsSubservertype error. That is expected, and it goes away once this PR lands.