Closed ViktorTigerstrom closed 1 month ago
Think this will be fixed by #8497 cc @ziggie1984
Yes as soon as we always do the cleanup we are fine and close the stop channel when triggering the shutdown.
Awesome, thanks! I just want to clarify though, that the ChannelRouter
Start
function will not return while the syncGraphWithChain
function is running. So only adding the Stop
function for the ChannelRouter
to the cleanUp
func in the server
, before the Start
function is executed won't really change the behaviour detailed in this issue unless I'm missing something?
You are right, thank you for the input will come up with a different solution.
Background
The
syncGraphWithChain
function inrouting/router.go
cannot be stopped by a shutdown signal while it's running. The function is ment to be able to exit early by closing the quit channel here: https://github.com/lightningnetwork/lnd/blob/fb632bb94565918dfa4a0aaa3b8544243e74e9f0/routing/router.go#L854But as the
syncGraphWithChain
function is synchronously called in theStart
function, theStop
function which closes the quit channel, can never be triggered until the syncing is complete. The only call-sites for theStop
function can only ever happen after theChannelRouter
Start
function has fully executed: https://github.com/lightningnetwork/lnd/blob/fb632bb94565918dfa4a0aaa3b8544243e74e9f0/server.go#L2020 & https://github.com/lightningnetwork/lnd/blob/fb632bb94565918dfa4a0aaa3b8544243e74e9f0/lnd.go#L681Steps to reproduce
To reproduce the issue, you can add some simple code to the beginning of the
syncGraphWithChain
function like the following:Then try to shutdown
lnd
with a shutdown signal while the code above is executing.Expected behaviour
The
syncGraphWithChain
function should exit early by a shutdown signal.Actual behaviour
lnd
will only shutdown after thesyncGraphWithChain
and theStart
function has finished their execution.