Skip to content

Commit

Permalink
Fix: clear difflayer cache when truncate not triggered (#141)
Browse files Browse the repository at this point in the history
  • Loading branch information
krish-nr authored Aug 20, 2024
1 parent 75729e0 commit 0effa90
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion trie/triedb/pathdb/disklayer.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,15 @@ import (
"sync"

"github.com/VictoriaMetrics/fastcache"
"golang.org/x/crypto/sha3"

"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/rawdb"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/ethdb"
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/trie/trienode"
"github.com/ethereum/go-ethereum/trie/triestate"
"golang.org/x/crypto/sha3"
)

// trienodebuffer is a collection of modified trie nodes to aggregate the disk
Expand Down Expand Up @@ -333,13 +334,15 @@ func (dl *diskLayer) commit(bottom *diffLayer, force bool) (*diskLayer, error) {
persistentID := rawdb.ReadPersistentStateID(dl.db.diskdb)
if limit >= persistentID {
log.Debug("No prune ancient under nodebufferlist, less than db config state history limit", "persistent_id", persistentID, "limit", limit)
bottom.cache.Remove(bottom)
return ndl, nil
}
targetOldest := persistentID - limit + 1
realOldest, err := dl.db.freezer.Tail()
if err == nil && targetOldest <= realOldest {
log.Info("No prune ancient under nodebufferlist due to truncate oldest less than real oldest, which maybe happened in abnormal restart",
"tartget_oldest_id", targetOldest, "real_oldest_id", realOldest, "error", err)
bottom.cache.Remove(bottom)
return ndl, nil
}
oldest = targetOldest
Expand Down

0 comments on commit 0effa90

Please sign in to comment.