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

fix indefinite retrying for cockroach quit when quorum is lost #14620 #14708

Merged
merged 1 commit into from
Apr 18, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 17 additions & 8 deletions pkg/cli/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -513,6 +513,10 @@ func runStart(cmd *cobra.Command, args []string) error {
case err := <-errChan:
return err
case <-stopper.ShouldStop():
// Server is being stopped externally and our job is finished
// here since we don't know if it's a graceful shutdown or not.
<-stopper.IsStopped()
return nil
case sig := <-signalCh:
log.Infof(shutdownCtx, "received signal '%s'", sig)
if sig == os.Interrupt {
Expand Down Expand Up @@ -729,17 +733,22 @@ func runQuit(_ *cobra.Command, _ []string) (err error) {
defer stopper.Stop()

ctx := stopperContext(stopper)

if err := doShutdown(ctx, c, onModes); err != nil {
if _, ok := err.(*errTryHardShutdown); ok {
fmt.Fprintf(
os.Stdout, "graceful shutdown failed: %s\nproceeding with hard shutdown\n", err,
)
} else {
errChan := make(chan error, 1)
go func() {
errChan <- doShutdown(ctx, c, onModes)
}()
select {
case err := <-errChan:
if err != nil {
if _, ok := err.(errTryHardShutdown); ok {
fmt.Printf("graceful shutdown failed: %s; proceeding with hard shutdown\n", err)
break
}
return err
}
} else {
return nil
case <-time.After(time.Minute):
fmt.Println("timed out; proceeding with hard shutdown")
}
// Not passing drain modes tells the server to not bother and go
// straight to shutdown.
Expand Down