Open nflaig opened 1 year ago
Another issue reported on discord, the BN process is not shutting down but based on the logs (beacon-2023-06-25.log) it is hard to tell what the issue is.
We might have to call process.exit explicitly after beacon node closed if this issue can't be resolved. https://github.com/ChainSafe/lodestar/blob/f5d12a893f5b913a04938275bb248ace1ca47539/packages/cli/src/cmds/beacon/handler.ts#L132
The issue seems to be fixed with upgrade to libp2p to 0.45.9 in 7280234bea66b49da3900b916a1b54c4666e4173.
The PR that fixed the issue:
Reopening as issue does not yet seem to be resolved.
Looks like we are pinging peers after sending goodbye
Jun-25 02:58:27.655[network] [34mdebug[39m: Req dialing peer method=goodbye, version=1, encoding=ssz_snappy, client=Lighthouse, peer=16...VYqoz3, requestId=295952
Jun-25 02:58:27.903[network] [34mdebug[39m: Req received method=ping, client=Lighthouse, peer=16...VYqoz3, requestId=295961
Jun-25 02:58:27.903[network] [36mverbose[39m: Resp done method=ping, client=Lighthouse, peer=16...VYqoz3, requestId=295961
or still dialing peers while disconnecting (goodbyeAndDisconnectAllPeers
)
Jun-25 02:58:28.311[network] [34mdebug[39m: Req dialing peer method=metadata, version=2, encoding=ssz_snappy, client=Unknown, peer=16...ohL5Xo, requestId=295963
Based on the current network close sequence it looks like we close the peer manager after disconnecting peers which could explain this behavior
as only after closing, the intervals and event listeners are removed
Changing the order of the closing sequence will likely fix the issue, but extensive testing is required as this issue is hard to reproduce.
Proposed solution https://github.com/ChainSafe/lodestar/issues/5642#issuecomment-1630749223 does not resolve the issue.
The problem seems to be with libp2p which in the end must take care of closing all connections / removing tcp listeners. There are several closed but also open issues regarding connections not being closed properly.
This comment https://github.com/libp2p/js-libp2p/issues/436#issuecomment-432624680 summarizes open tasks but there was no progress in a while.
For now, we just have to explicitly exit process until upstream issues are fixed.
Potential fix has been merged to unstable
It is hard to verify if this actually fixed the issue due to the fact that it is not really reproducible and happens rarely.
Two things have to be done to confirm a fix
--network.useWorker false
andNote: there is a chance that the process would also hang with --network.useWorker true
set (https://github.com/ChainSafe/lodestar/issues/5775 <-- this issue was still observed recently) but this happened even less often, hence it is harder to confirm a fix of the issue.
Describe the bug
In some rare cases when the node is running for a longer time it does not exit when receiving a exit signal.
Active handles
The Sockets that show
135.181.2.45:9000 -> undefined:undefined
can probably be ignored as those are also there if beacon node exits correctly.Debug logs
What looks really suspicious is that we are dialing peers after network is already closed
Expected behavior
Beacon node should always exit process after close sequence succeeds. No explicit process.exit should be required.
Steps to reproduce
Run beacon node for a while with the following command (or similar)
CTRL + C to exit gracefully and observe that it is not shutting down even though close sequence is executed successfully.
Operating system
Linux
Lodestar version or commit hash
unstable (bf5842733a738c59a6f9aa147496806fb2d4c98f)