manager: Fix hanging Stop method#2203
Merged
aaronlehmann merged 1 commit intomoby:masterfrom May 25, 2017
Merged
Conversation
This was referenced May 24, 2017
Contributor
|
LGTM |
| n.stopMu.Lock() | ||
| // to shutdown transport | ||
| close(n.stopped) | ||
| n.cancelFunc() |
Contributor
There was a problem hiding this comment.
I'm not very familiar with this part of the code, but I didn't follow why this change is needed.
Contributor
There was a problem hiding this comment.
I think this would make it safer to call manager.Stop() even after JoinAndStart errors, because if JoinAndStart errors the channel is closed, and manager.Stop() calls raft.Node.Cancel(), which calls n.cancelFunc.
Contributor
There was a problem hiding this comment.
@cyli thanks for the explanation, I understand better now.
If raftNode.JoinAndStart failed, Stop will block forever because it waits for the manager to start up. To fix this, close the "started" channel even if Run exits early due to an error. Fix the way the collector is initialized so its Stop method won't hang either. Add a test that makes sure the node shuts down cleanly after a failed manager initialization. Signed-off-by: Aaron Lehmann <aaron.lehmann@docker.com>
3478145 to
cc882cf
Compare
Codecov Report
@@ Coverage Diff @@
## master #2203 +/- ##
==========================================
- Coverage 60.19% 59.94% -0.25%
==========================================
Files 119 119
Lines 19835 19849 +14
==========================================
- Hits 11939 11898 -41
- Misses 6549 6604 +55
Partials 1347 1347 |
23 tasks
dongluochen
approved these changes
May 25, 2017
aluzzardi
added a commit
to aluzzardi/docker-ce
that referenced
this pull request
Jun 1, 2017
Includes moby/swarmkit#2203 Signed-off-by: Andrea Luzzardi <aluzzardi@gmail.com>
tiborvass
pushed a commit
to aluzzardi/docker-ce
that referenced
this pull request
Jun 6, 2017
Includes: - moby/swarmkit#2203 - moby/swarmkit#2210 - moby/swarmkit#2212 Signed-off-by: Andrea Luzzardi <aluzzardi@gmail.com> Signed-off-by: Tibor Vass <tibor@docker.com>
silvin-lubecki
pushed a commit
to silvin-lubecki/docker-ce
that referenced
this pull request
Feb 3, 2020
Includes: - moby/swarmkit#2203 - moby/swarmkit#2210 - moby/swarmkit#2212 Signed-off-by: Andrea Luzzardi <aluzzardi@gmail.com> Signed-off-by: Tibor Vass <tibor@docker.com>
silvin-lubecki
pushed a commit
to silvin-lubecki/engine-extract
that referenced
this pull request
Feb 3, 2020
Includes: - moby/swarmkit#2203 - moby/swarmkit#2210 - moby/swarmkit#2212 Signed-off-by: Andrea Luzzardi <aluzzardi@gmail.com> Signed-off-by: Tibor Vass <tibor@docker.com>
silvin-lubecki
pushed a commit
to silvin-lubecki/engine-extract
that referenced
this pull request
Mar 10, 2020
Includes: - moby/swarmkit#2203 - moby/swarmkit#2210 - moby/swarmkit#2212 Signed-off-by: Andrea Luzzardi <aluzzardi@gmail.com> Signed-off-by: Tibor Vass <tibor@docker.com>
silvin-lubecki
pushed a commit
to silvin-lubecki/engine-extract
that referenced
this pull request
Mar 23, 2020
Includes: - moby/swarmkit#2203 - moby/swarmkit#2210 - moby/swarmkit#2212 Signed-off-by: Andrea Luzzardi <aluzzardi@gmail.com> Signed-off-by: Tibor Vass <tibor@docker.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
If
raftNode.JoinAndStartfailed,Stopwill block forever because it waits for the manager to start up.To fix this, close the "started" channel even if Run exits early due to an error. Fix the way the collector is initialized so its
Stopmethod won't hang either.Add a test that makes sure the node shuts down cleanly after a failed manager initialization.
cc @cyli