miner, consensus/clique: avoid memory leak during block stasis #23861
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When a clique network is not progressing, we see a memory leak:
This is pretty bad, because whenever one signer falls off, then the rest of them eventually will crash too -- so one failing sealer will wreak havoc, causing other sealers to crash and making it very difficult to get the network live again.
Every
3
seconds (miner.recommit
interval) we shove a new task to be handed, where we e.g. deep-copy the receipts and other stuff and send it over a channelw.taskCh <- &task{receipts: receipts, state: s, block: block, createdAt: time.Now()}:
That get's shoved into a map
So every 3 seconds (miner recommit), we leak a block into memory, basically.
The routine that would have cleaned that up :
Won't clean close to head, and besides, it's not executed unless blocks progress.
When we hit this case:
Then
Signed recently, must wait for others
means that we did not actually start a sealing-task at all, so there's no point tracking the work package. This PR changes the behavior so that