Skip to content

Commit

Permalink
Merge pull request etcd-io#16423 from chenyang8094/fix-raftexample-pa…
Browse files Browse the repository at this point in the history
…nic-when-reduce-snapshot-count

Handle ErrCompacted errors for Compact in raftexample
  • Loading branch information
ahrtr committed Aug 18, 2023
2 parents 6ef9c53 + 68db708 commit 39aad38
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions contrib/raftexample/raft.go
Original file line number Diff line number Diff line change
Expand Up @@ -392,10 +392,13 @@ func (rc *raftNode) maybeTriggerSnapshot(applyDoneC <-chan struct{}) {
compactIndex = rc.appliedIndex - snapshotCatchUpEntriesN
}
if err := rc.raftStorage.Compact(compactIndex); err != nil {
panic(err)
if err != raft.ErrCompacted {
panic(err)
}
} else {
log.Printf("compacted log at index %d", compactIndex)
}

log.Printf("compacted log at index %d", compactIndex)
rc.snapshotIndex = rc.appliedIndex
}

Expand Down

0 comments on commit 39aad38

Please sign in to comment.