Skip to content

Commit

Permalink
issue358 Snapshot can attempt to delete a negative range from log (ha…
Browse files Browse the repository at this point in the history
…shicorp#362)

* issue358 Snapshot can attempt to delete a negative range from log

* issue 358 change it to strict inequality
  • Loading branch information
jscode017 authored and banks committed Sep 23, 2019
1 parent c53e736 commit 7b09f38
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions snapshot.go
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,11 @@ func (r *Raft) compactLogs(snapIdx uint64) error {
// after the snapshot to be removed.
maxLog := min(snapIdx, lastLogIdx-r.conf.TrailingLogs)

if minLog > maxLog {
r.logger.Info("no logs to truncate")
return nil
}

r.logger.Info("compacting logs", "from", minLog, "to", maxLog)

// Compact the logs
Expand Down

0 comments on commit 7b09f38

Please sign in to comment.