-
Notifications
You must be signed in to change notification settings - Fork 2.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
nsqd: handle repeated calls to Exit() #1331
Conversation
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.
This seems to work fine. I'm not sure if a better refactoring of the whole go-svc signal-handling thing is in order, but that would be a lot more work to review, and this is rather small. Seems like a good fix for now. 👍
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.
Just pushed up an alternative approach here (requires landing something like the following in go-svc
judwhite/go-svc@main...mreiferson:signal-handler).
Edit: I realize this is an interface change to go-svc
but, implementation aside, it feels like the right thing to expose to the application (the ability to act on signals without hacks).
I had to remind myself what this all was for ... it's What's awkward is the With the code in current master, the "bug" is arguably this (which mreiferson removes): // This is a noop after first call
func (n *NSQD) TermSignal() {
n.Exit()
} because it seems like func (p *program) Stop() error {
p.once.Do(func() {
p.nsqd.Exit()
})
return nil
} So you probably figured this out already, I'm just reminding myself ... and also pointing out that mreiferson's solution moves the problem from the exit-signal case to the drain-signal case, which doesn't exist yet, but will have to change it yet again. Maybe the Anyway I do prefer the |
Yes, that is the current expectation. I'm fine with a change as part of #1305 to ensure that |
I agree that comes out cleanly; @mreiferson do you want to work on upstreaming that then we can switch to that pattern when it's available upstream?
If Exit can only be called once this feels like something that feels like something to be implemented in We can also fix this interim bug by switching the term signal handler from |
Will do.
Agreed, and I'm fine with however way we want to implement it (atomic var or
Somewhat related to the previous point, I don't think a method called |
@mreiferson 🤕 Yes, that's a much better name. |
954e32b
to
9f16b60
Compare
PTAL @mreiferson I've updated to remove the |
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.
LGTM
This extracts handling from #1305 to handle repeated calls to nsqd.Exit(). This regression was introduced in #1319
Fixes #1326