eth: close miner on exit (instead of just stopping)#21992
eth: close miner on exit (instead of just stopping)#21992fjl merged 3 commits intoethereum:masterfrom
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 |
fjl
left a comment
There was a problem hiding this comment.
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.
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 <fjl@twurst.com>
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 <fjl@twurst.com>
This PR fixes #19965, I think.
Previously, when shutting down the Ethereum service, the miner was stopped before the blockchain, which is fine. However,
StopandCloseare diferent:The
Stoptells the worker routine to stop, but stays in the loop. TheClosecauses 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.runningto0, butclosealso 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.