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

stop: allow double-calling Stop() #34823

Merged
merged 1 commit into from
Feb 12, 2019
Merged

Conversation

tbg
Copy link
Member

@tbg tbg commented Feb 12, 2019

Stop() can be called multiple times and it's better to embrace that fact
than to try to fight it. See

cockroach/pkg/cli/start.go

Lines 794 to 809 in 89ce71e

}
stopper.Stop(drainCtx)
}()
// Don't return: we're shutting down gracefully.
case <-log.FatalChan():
// A fatal error has occurred. Stop everything (gracelessly) to
// avoid serving incorrect data while the final log messages are
// being written.
// https://github.com/cockroachdb/cockroach/issues/23414
// TODO(bdarnell): This could be more graceless, for example by
// reaching into the server objects and closing all the
// connections while they're in use. That would be more in line
// with the expected effect of a log.Fatal.
stopper.Stop(shutdownCtx)

Fixes #34572

Release note (bug fix): Fix a rare crash ("close of closed channel")
that could occur when shutting down a server.

Stop() can be called multiple times and it's better to embrace that fact
than to try to fight it. See

https://github.com/cockroachdb/cockroach/blob/89ce71e9b733df3855b370aa20bb809db3d4362c/pkg/cli/start.go#L794-L809

Fixes cockroachdb#34572

Release note (bug fix): Fix a rare crash ("close of closed channel")
that could occur when shutting down a server.
@tbg tbg requested a review from knz February 12, 2019 11:49
@cockroach-teamcity
Copy link
Member

This change is Reviewable

Copy link
Collaborator

@petermattis petermattis left a comment

Choose a reason for hiding this comment

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

:lgtm:

Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @knz)

@tbg
Copy link
Member Author

tbg commented Feb 12, 2019

bors r=petermattis,knz

TFTRs

craig bot pushed a commit that referenced this pull request Feb 12, 2019
34823: stop: allow double-calling Stop() r=petermattis,knz a=tbg

Stop() can be called multiple times and it's better to embrace that fact
than to try to fight it. See

https://github.com/cockroachdb/cockroach/blob/89ce71e9b733df3855b370aa20bb809db3d4362c/pkg/cli/start.go#L794-L809

Fixes #34572

Release note (bug fix): Fix a rare crash ("close of closed channel")
that could occur when shutting down a server.

Co-authored-by: Tobias Schottdorf <tobias.schottdorf@gmail.com>
@craig
Copy link
Contributor

craig bot commented Feb 12, 2019

Build succeeded

@craig craig bot merged commit 518f739 into cockroachdb:master Feb 12, 2019
@tbg tbg deleted the fix/double-stop branch March 13, 2019 11:51
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.

sentry: stopper.go:182: runtime.plainError: close of closed channel
4 participants