-
Notifications
You must be signed in to change notification settings - Fork 3.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cli: quit command waits for server shutdown #7603
Conversation
ctx := stream.Context() | ||
|
||
select { | ||
case <-s.server.stopper.IsStopped(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does the stopper close all the listeners? And the connection is still available and can communicate with the client?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, the stopper closes the connection - see the code on the client side that expressly waits for this to happen.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the stopper closes the connection first and then stops some other stuff after, why does the client know that the server has completely terminated by the time its connection is closed? I see what the intention of the code is, but I don't see at all why it works.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All those things happen already after the stopper is Quiesce()
d and Wait()
ed, so all the stopper is doing before process death is:
for _, c := range s.closers {
c.Close()
}
close(s.stopped)
There's a race here, but I just don't see how we can do any better (short of adding yet another phase to the stopper so that connections are the last thing to go).
I just can't convince myself that there isn't a race that actually makes the shutdown experience worse. A clean solution would close all the server listeners (and generally file descriptors) first, and then the client connection (as you point out above). |
Well, I do think it's a strict improvement. Do I have your blessing to merge? |
I don't see much won here except a chance for random errors on shutdown, so On Sat, Jul 2, 2016 at 10:53 AM Tamir Duberstein [email protected]
-- Tobias |
I do not really like the complexity added by this PR. In my view the simpler approach would be to:
Review status: 0 of 5 files reviewed at latest revision, 2 unresolved discussions, all commit checks successful. cli/start.go, line 521 [r1] (raw file):
I do not like the meaning of encountering an error here. What is the state of the server then? Comments from Reviewable |
Introducing bidirectional communication to the Review status: 0 of 5 files reviewed at latest revision, 2 unresolved discussions, all commit checks successful. cli/start.go, line 521 [r1] (raw file):
|
As I explained to tamir I do not have a better solution in mind. So of course I'll sign off on this since it brings us closer to a solution. See my comments about code structure below however. Reviewed 5 of 5 files at r1. cli/start.go, line 526 [r1] (raw file):
I;d suggest turning this entire block into its own function and call the same functions 2 times. The code replication here is unnerving. cli/start.go, line 528 [r1] (raw file):
Please add a comment here to remind the reader why not having "onModes" means the server should perform a hard shutdown. server/admin.go, line 691 [r1] (raw file):
|
Review status: all files reviewed at latest revision, 4 unresolved discussions, all commit checks successful. cli/start.go, line 526 [r1] (raw file):
|
Reviewed 1 of 1 files at r2. cli/start.go, line 526 [r1] (raw file):
|
Review status: all files reviewed at latest revision, 3 unresolved discussions, all commit checks successful. cli/start.go, line 526 [r1] (raw file):
|
Closes #6585.
This change is![Reviewable](https://camo.githubusercontent.com/1541c4039185914e83657d3683ec25920c672c6c5c7ab4240ee7bff601adec0b/68747470733a2f2f72657669657761626c652e696f2f7265766965775f627574746f6e2e737667)