From ecc7a2583816518c77d1aa0688ea719a871ab101 Mon Sep 17 00:00:00 2001 From: Krish Date: Tue, 20 Aug 2024 09:11:32 +0800 Subject: [PATCH] clear difflayer cache when truncate not triggered --- trie/triedb/pathdb/disklayer.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/trie/triedb/pathdb/disklayer.go b/trie/triedb/pathdb/disklayer.go index 60c891fd2c..a0cb6f25a9 100644 --- a/trie/triedb/pathdb/disklayer.go +++ b/trie/triedb/pathdb/disklayer.go @@ -22,6 +22,8 @@ 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" @@ -29,7 +31,6 @@ import ( "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 @@ -333,6 +334,7 @@ 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 @@ -340,6 +342,7 @@ func (dl *diskLayer) commit(bottom *diffLayer, force bool) (*diskLayer, error) { 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