prevent dependencies from being added after stop #1898
Merged
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.
A Nomad user reported an issue where
View.poll
goroutines were being leaked when using large templates. When the runner'sRun
method is in-flight and the runner concurrently receivesStop
, it's possible for the watcher to stop dependencies via stop and then immediately recreate them. Because theStop
method has returned, the caller will assume that all goroutines have been stopped, and this causes theView.poll
goroutines to be leaked. The race condition for this case is very narrow, but is most likely to occur when the user has both a very large number of dependencies, short secret leases, and theWait
configuration is nil.Add a
stopped
flag to theWatcher
which is set onStop
, and check whether this field has been set before adding a new dependency.Ref: hashicorp/nomad#20163