-
Notifications
You must be signed in to change notification settings - Fork 20.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
eth: close miner on exit (instead of just stopping) #21992
Conversation
I would love to see this in master soon, we update our rinkeby signer bi-weekly and we hit this panic pretty much every time. edit: I added more logs to #19965, hope they help |
@rjl493456442 PTAL |
ping @rjl493456442 PTAL |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please also add a sync.WaitGroup in miner/miner.go to wait for the shutdown of the Miner.update goroutine when Miner.Close is called.
Fixed, ptal. I have not tested it yet, let's see what the tests say first |
I'll put this PR on one of our PoA signers |
rebased |
worker.wg.Add(4) | ||
go worker.mainLoop() | ||
go worker.newWorkLoop(recommit) | ||
go worker.resultLoop() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm suggesting an approach which I think makes managing the wg a bit easier, by keeping all the code contained in one place.
worker.wg.Add(4) | |
go worker.mainLoop() | |
go worker.newWorkLoop(recommit) | |
go worker.resultLoop() | |
worker.wg.Add(4) | |
go func() { | |
defer worker.wg.Done() | |
worker.mainLoop() | |
}() | |
go func() { | |
defer worker.wg.Done() | |
worker.newWorkLoop(recommit) | |
}() | |
go func() { | |
defer worker.wg.Done() | |
worker.resultLoop() | |
}() | |
go func() { | |
defer worker.wg.Done() | |
worker.taskLoop() | |
}() |
This ensures that all miner goroutines have exited before stopping the blockchain. Co-authored-by: Felix Lange <[email protected]>
eth: close miner on exit (instead of just stopping) (ethereum#21992)
This ensures that all miner goroutines have exited before stopping the blockchain. Co-authored-by: Felix Lange <[email protected]>
This PR fixes #19965, I think.
Previously, when shutting down the Ethereum service, the miner was stopped before the blockchain, which is fine. However,
Stop
andClose
are diferent:The
Stop
tells the worker routine to stop, but stays in the loop. TheClose
causes the miner to also shut down the worker routine, and then exit the main loop:In the worker, it's also different:
They both set
w.running
to0
, butclose
also signals on the exitCh, which causes the worker loop to exit, and thus not do any more commit operations.I'm fairly sure this change is for the better, however, I'm not 100% sure it solves the issue, since we're closing the
worker.exitCh
, but we don't actually wait for the worker to react to it -- so there's still a potential commit operation already happening.If the issue still persist, we might do better by also adding a waitgroup to wait for the miner workers to actually exit before allowing the blockchain to shut down.