Skip to content

Commit

Permalink
consolidate empty wal entries error logs in one warning (#1393)
Browse files Browse the repository at this point in the history
* remove empty wal entries

* trim first empty entries, EOF error is a warning

* consolidated log for empty tries
  • Loading branch information
baptiste-b-pegasys authored May 12, 2022
1 parent ff50fd3 commit 7466389
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions 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 @@ -484,10 +485,14 @@ func (pm *ProtocolManager) startRaft() {
// chain and all other nodes in the network have confirmed these blocks
if maybeRaftSnapshot != nil {
currentChainHead := pm.blockchain.CurrentBlock().Number()
for _, entry := range entries {
emptyEntries := make([]int, 0, len(entries))
for idx, 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 {
emptyEntries = append(emptyEntries, idx)
continue
} else if err != nil {
log.Error("error decoding block: ", "err", err)
continue
}
Expand All @@ -505,6 +510,9 @@ func (pm *ProtocolManager) startRaft() {
}
}
}
if len(emptyEntries) > 0 {
log.Warn("empty wal entries", "index", emptyEntries)
}
}

if hardState, _, err := pm.raftStorage.InitialState(); err != nil {
Expand Down

0 comments on commit 7466389

Please sign in to comment.