Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
26163: release-2.0: cli: fix `cockroach quit` r=knz a=knz

Backport 1/1 commits from cockroachdb#26158.

This `cockroach quit` bug is likely to affect production users, so we need to back-port it.

/cc @cockroachdb/release


Co-authored-by: Raphael 'kena' Poss <[email protected]>
  • Loading branch information
craig[bot] and knz committed Jun 8, 2018
2 parents 822858a + f0fc0d5 commit 59616c0
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions pkg/cli/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -1042,6 +1042,9 @@ func doShutdown(ctx context.Context, c serverpb.AdminClient, onModes []int32) er
// out, or perhaps drops the connection while waiting). To that end, we first
// run a noop DrainRequest. If that fails, we give up.
if err := checkNodeRunning(ctx, c); err != nil {
if grpcutil.IsClosedConnection(err) {
return nil
}
return err
}
// Send a drain request and continue reading until the connection drops (which
Expand Down Expand Up @@ -1113,16 +1116,21 @@ func runQuit(cmd *cobra.Command, args []string) (err error) {
case err := <-errChan:
if err != nil {
if _, ok := err.(errTryHardShutdown); ok {
fmt.Printf("graceful shutdown failed: %s; proceeding with hard shutdown\n", err)
log.Warningf(ctx, "graceful shutdown failed: %s; proceeding with hard shutdown\n", err)
break
}
return err
}
return nil
case <-time.After(time.Minute):
fmt.Println("timed out; proceeding with hard shutdown")
log.Warningf(ctx, "timed out; proceeding with hard shutdown")
}
// Not passing drain modes tells the server to not bother and go
// straight to shutdown.
// straight to shutdown. We try two times just in case there is a transient error.
err = doShutdown(ctx, c, nil)
if err != nil {
log.Warningf(ctx, "hard shutdown attempt failed, retrying: %v", err)
err = doShutdown(ctx, c, nil)
}
return errors.Wrap(doShutdown(ctx, c, nil), "hard shutdown failed")
}

0 comments on commit 59616c0

Please sign in to comment.