Skip to content

Commit

Permalink
remove empty wal entries
Browse files Browse the repository at this point in the history
  • Loading branch information
baptiste-b-pegasys committed May 3, 2022
1 parent e95f163 commit bc0552f
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions raft/wal.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,16 @@ func (pm *ProtocolManager) replayWAL(maybeRaftSnapshot *raftpb.Snapshot) (*wal.W
fatalf("failed to read WAL: %s", err)
}

// filter empty entries
newEntries := make([]raftpb.Entry, 0, len(entries))
for i := range entries {
if len(entries[i].Data) > 0 {
newEntries = append(newEntries, entries[i])
}
}

pm.raftStorage.SetHardState(hardState)
pm.raftStorage.Append(entries)
pm.raftStorage.Append(newEntries)

return wal, entries
return wal, newEntries
}

0 comments on commit bc0552f

Please sign in to comment.