-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
pkg/receive: remove deadlock on interrupt #1231
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.
Nice finding! Some suggestion (:
pkg/receive/handler.go
Outdated
return httpSrv.Serve(listener) | ||
}, func(error) { | ||
go func() { | ||
<-ctx.Done() | ||
runutil.CloseWithLogOnErr(h.logger, listener, "receive HTTP listener") |
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.
Why not having handler.Close
method and closing listener there? And having Close()
method invoked in root oklog/run
? Would be more explicit and consistent? (:
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 absolutely sounds good, I assumed we were using context for consistency :)
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.
Hard to say about any consistency here.. but you are right we mix things everywhere in this space. (: We can do both, but this sounds like extra hidden go routine (:
d7a3a2e
to
a12c79e
Compare
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 (:
cmd/thanos/receive.go
Outdated
g.Add( | ||
func() error { | ||
if err := webHandler.Run(ctx); err != nil { | ||
if err := webHandler.Run(); err != nil { | ||
return fmt.Errorf("error starting web server: %s", err) |
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.
errors.Wrap
instead, also I am 90% sure Run
will never return nil error (: Not a blocker.
func (h *Handler) Quit() <-chan struct{} { | ||
return h.quitCh | ||
// Close stops the Handler. | ||
func (h *Handler) Close() { |
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.
Much more cleaner ❤️
Currently, the receive component blocks indefinitely when the Thanos process is interrupted because the given context is not actually used to stop the server.
Thanks! lgtm 👍 |
Currently, the receive component blocks indefinitely when the Thanos process is interrupted because the given context is not actually used to stop the server.
Changes
Currently, the receive component blocks indefinitely when the Thanos
process is interrupted because the given context is not actually used
to stop the server.
Verification
cc @brancz @bwplotka