This repository has been archived by the owner on Aug 2, 2021. It is now read-only.
Fix goroutine leak by closing accounts manager on Node.Stop #1147
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.
Fixes: #1142
While performing the test described in #1142 issue, a large number of gorutines were created and not terminated. Stack trace shows many goroutines:
Accounts manager is created but not closed for node.Node, leaving large number of goroutines alive. This change closes accounts manager on Node.Stop, but Node initializes accounts manager in constructor, not no Start, so for Restart and Start to work as expected, accounts manager construction and closing is handled in Start as well, preserving the original required initialization in constructor.
Keystore watch creates fs watchers and we have noticed before a lot of
(FSEvents.framework) FSEventStreamStart: register_with_server: ERROR: f2d_register_rpc() => (null) (-21)
errors on macOS while running a large scale simulations. This change may improve simulations performance as it closes unneeded file watchers.Note: Running tests described in #1142
time go test -race -count 100 github.com/ethereum/go-ethereum/swarm/network/simulation
require changes from PR ethereum/go-ethereum#18464 to fix race conditions, but this PR solves goroutine leak. This tests run for about 20 minutes.