Skip to content

Commit

Permalink
cli: fix debug zip nil pointer dereference
Browse files Browse the repository at this point in the history
Fix a nil pointer dereference in `debug zip` when a few nodes are down,
but the cluster is otherwise above quorum. Extended the existing
`debug/nodes=3` roachtest to tickle this problem which was not occurring
previously because that test was checking `debug zip` when all but 1
node was down.

Fixes #35358

Release note (bug fix): Fix a nil pointer dereference in `debug zip`
when one or more nodes in the cluster are down.
  • Loading branch information
petermattis committed Mar 5, 2019
1 parent 016d5ef commit 63448fb
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
6 changes: 4 additions & 2 deletions pkg/cli/zip.go
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ func runDebugZip(cmd *cobra.Command, args []string) error {
err = contextutil.RunWithTimeout(baseCtx, "request stacks", timeout,
func(ctx context.Context) error {
stacks, err := status.Stacks(ctx, &serverpb.StacksRequest{NodeId: id})
if err != nil {
if err == nil {
stacksData = stacks.Data
}
return err
Expand All @@ -291,7 +291,9 @@ func runDebugZip(cmd *cobra.Command, args []string) error {
NodeId: id,
Type: serverpb.ProfileRequest_HEAP,
})
heapData = heap.Data
if err == nil {
heapData = heap.Data
}
return err
})
if err := z.createRawOrError(prefix+"/heap", heapData, err); err != nil {
Expand Down
13 changes: 11 additions & 2 deletions pkg/cmd/roachtest/debug.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,17 @@ func registerDebug(r *registry) {

waitForFullReplication(t, db)

// Kill first nodes-1 nodes.
for i := 1; i < nodes; i++ {
// Kill the first node and verify debug zip can be generated with one node
// down.
c.Stop(ctx, c.Node(1))

// Run debug zip command against the second node.
if err := debugExtractExist(2, "output.zip"); err != nil {
t.Fatal(err)
}

// Kill all but the last node.
for i := 2; i < nodes; i++ {
c.Stop(ctx, c.Node(i))
}

Expand Down

0 comments on commit 63448fb

Please sign in to comment.