eth: close engine before handler for graceful shutdown (#1189)

This commit is contained in:
Manav Darji 2024-04-15 10:38:09 +05:30 committed by GitHub
parent ffe810e55a
commit f6969dbc46
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -822,6 +822,12 @@ func (s *Ethereum) Stop() error {
// Stop all the peer-related stuff first.
s.ethDialCandidates.Close()
s.snapDialCandidates.Close()
// Close the engine before handler else it may cause a deadlock where
// the heimdall is unresponsive and the syncing loop keeps waiting
// for a response and is unable to proceed to exit `Finalize` during
// block processing.
s.engine.Close()
s.handler.Stop()
// Then stop everything else.
@ -834,7 +840,6 @@ func (s *Ethereum) Stop() error {
s.txPool.Close()
s.miner.Close()
s.blockchain.Stop()
s.engine.Close()
// Clean shutdown marker as the last thing before closing db
s.shutdownTracker.Stop()