Skip to content

Commit

Permalink
Merge pull request #13880 from ahrtr/fix_dump_logs_panic
Browse files Browse the repository at this point in the history
etcd-dump-logs will panic if there is no WAL entry after the snapshot
  • Loading branch information
ptabor authored Apr 6, 2022
2 parents ad03f20 + 543c87c commit 047e61d
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions tools/etcd-dump-logs/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,10 @@ and output a hex encoded line of binary for each input line`)
fmt.Printf("WAL metadata:\nnodeID=%s clusterID=%s term=%d commitIndex=%d vote=%s\n",
id, cid, state.Term, state.Commit, vid)

fmt.Printf("WAL entries:\n")
fmt.Printf("lastIndex=%d\n", ents[len(ents)-1].Index)
fmt.Printf("WAL entries: %d\n", len(ents))
if len(ents) > 0 {
fmt.Printf("lastIndex=%d\n", ents[len(ents)-1].Index)
}

fmt.Printf("%4s\t%10s\ttype\tdata", "term", "index")
if *streamdecoder != "" {
Expand Down

0 comments on commit 047e61d

Please sign in to comment.