From 227cc3a45c15739b16ac91e513c15bc532aec8fa Mon Sep 17 00:00:00 2001 From: yyforyongyu Date: Sat, 2 Nov 2024 11:21:42 +0800 Subject: [PATCH 1/2] routing: fix missionControlStore blocks on shutting down --- routing/missioncontrol_store.go | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/routing/missioncontrol_store.go b/routing/missioncontrol_store.go index ceb4740e44..5f4f521f5c 100644 --- a/routing/missioncontrol_store.go +++ b/routing/missioncontrol_store.go @@ -50,6 +50,9 @@ type missionControlStore struct { wg sync.WaitGroup db missionControlDB + // TODO(yy): Remove the usage of sync.Cond - we are better off using + // channes than a Cond as suggested in the official godoc. + // // queueCond is signalled when items are put into the queue. queueCond *sync.Cond @@ -347,8 +350,14 @@ func (b *missionControlStore) run() { // Wait for the queue to not be empty. b.queueCond.L.Lock() for b.queue.Front() == nil { - b.queueCond.Wait() - + // To make sure we can properly stop, we must + // read the `done` channel first before + // attempting to call `Wait()`. This is due to + // the fact when `Signal` is called before the + // `Wait` call, the `Wait` call will block + // indefinitely. + // + // TODO(yy): replace this with channels. select { case <-b.done: b.queueCond.L.Unlock() @@ -356,6 +365,8 @@ func (b *missionControlStore) run() { return default: } + + b.queueCond.Wait() } b.queueCond.L.Unlock() From 4fe36f1887f8a9ee2a61c3cbfbba428d8d8c64e8 Mon Sep 17 00:00:00 2001 From: yyforyongyu Date: Fri, 8 Nov 2024 01:53:07 +0800 Subject: [PATCH 2/2] docs: add release notes --- docs/release-notes/release-notes-0.19.0.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/docs/release-notes/release-notes-0.19.0.md b/docs/release-notes/release-notes-0.19.0.md index 2bbcc4d589..02bdbdbc24 100644 --- a/docs/release-notes/release-notes-0.19.0.md +++ b/docs/release-notes/release-notes-0.19.0.md @@ -40,6 +40,9 @@ a graceful shutdown of LND during the main chain backend sync check in certain cases. +* [Fixed a bug](https://github.com/lightningnetwork/lnd/pull/9249) found in the + mission control store that can block the shutdown process of LND. + # New Features ## Functional Enhancements ## RPC Additions