Skip to content

Commit

Permalink
Fixing log truncation with too few logs
Browse files Browse the repository at this point in the history
  • Loading branch information
armon committed Jun 20, 2014
1 parent cb7f050 commit 596cfa1
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions raft.go
Original file line number Diff line number Diff line change
Expand Up @@ -1643,6 +1643,11 @@ func (r *Raft) compactLogs(snapIdx uint64) error {
return fmt.Errorf("failed to get first log index: %v", err)
}

// Check if we have enough logs to truncate
if r.getLastLogIndex() <= r.conf.TrailingLogs {
return nil
}

// Truncate up to the end of the snapshot, or `TrailingLogs`
// back from the head, which ever is futher back. This ensures
// at least `TrailingLogs` entries, but does not allow logs
Expand Down

0 comments on commit 596cfa1

Please sign in to comment.