Skip to content

Commit

Permalink
revert trim empty entries, change log to warning
Browse files Browse the repository at this point in the history
  • Loading branch information
baptiste-b-pegasys committed May 3, 2022
1 parent bc0552f commit a32be30
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 11 deletions.
6 changes: 5 additions & 1 deletion raft/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"errors"
"fmt"
"io"
"net"
"net/http"
"net/url"
Expand Down Expand Up @@ -487,7 +488,10 @@ func (pm *ProtocolManager) startRaft() {
for _, entry := range entries {
if entry.Type == raftpb.EntryNormal {
var block types.Block
if err := rlp.DecodeBytes(entry.Data, &block); err != nil {
if err := rlp.DecodeBytes(entry.Data, &block); err == io.EOF {
log.Warn("empty entry from raft")
continue
} else if err != nil {
log.Error("error decoding block: ", "err", err)
continue
}
Expand Down
12 changes: 2 additions & 10 deletions raft/wal.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,8 @@ 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(newEntries)
pm.raftStorage.Append(entries)

return wal, newEntries
return wal, entries
}

0 comments on commit a32be30

Please sign in to comment.