Skip to content
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

Merged
merged 1 commit into from
Jun 6, 2019
Merged

Conversation

squat
Copy link
Member

@squat squat commented Jun 6, 2019

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.

  • This change adjusts the receive Handler struct to quit on context done.
  • Remove unused quit chan

Verification

  • start the receive component;
  • send SIGINT
  • verify that before the change the process does not exit
  • verify that after fix process does exit

cc @brancz @bwplotka

Copy link
Member

@bwplotka bwplotka left a 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 (:

return httpSrv.Serve(listener)
}, func(error) {
go func() {
<-ctx.Done()
runutil.CloseWithLogOnErr(h.logger, listener, "receive HTTP listener")
Copy link
Member

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? (:

Copy link
Member Author

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 :)

Copy link
Member

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 (:

@squat squat force-pushed the deadlock branch 2 times, most recently from d7a3a2e to a12c79e Compare June 6, 2019 10:48
Copy link
Member

@bwplotka bwplotka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM (:

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)
Copy link
Member

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() {
Copy link
Member

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.
@brancz
Copy link
Member

brancz commented Jun 6, 2019

Thanks! lgtm 👍

@brancz brancz merged commit 6820ae0 into thanos-io:master Jun 6, 2019
FUSAKLA pushed a commit to FUSAKLA/thanos that referenced this pull request Jun 8, 2019
Currently, the receive component blocks indefinitely when the Thanos
process is interrupted because the given context is not actually used
to stop the server.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants