Skip to content

Commit

Permalink
fix: flush base buffer at startup
Browse files Browse the repository at this point in the history
  • Loading branch information
will@2012 committed May 23, 2024
1 parent ee34128 commit e959def
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions trie/triedb/pathdb/nodebufferlist.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,11 +128,12 @@ func newNodeBufferList(
waitForceKeepCh: make(chan struct{}),
keepFunc: keepFunc,
}

go nf.loop()

log.Info("new node buffer list", "proposed block interval", nf.wpBlocks,
"reserve multi difflayers", nf.rsevMdNum, "difflayers in multidifflayer", nf.dlInMd,
"limit", common.StorageSize(limit), "layers", layers, "persist id", nf.persistID)
"limit", common.StorageSize(limit), "layers", layers, "persist id", nf.persistID, "base_size", size)
return nf
}

Expand Down Expand Up @@ -517,6 +518,7 @@ func (nf *nodebufferlist) diffToBase() {

// backgroundFlush flush base node buffer to disk.
func (nf *nodebufferlist) backgroundFlush() {
log.Info("Start to background flush")
nf.flushMux.Lock()
defer nf.flushMux.Unlock()
nf.baseMux.RLock()
Expand Down Expand Up @@ -590,7 +592,7 @@ func (nf *nodebufferlist) loop() {
continue
}
nf.diffToBase()
if nf.base.size > nf.base.limit {
if nf.base.size >= nf.base.limit {
nf.backgroundFlush()
}
nf.isFlushing.Swap(false)
Expand Down Expand Up @@ -859,6 +861,7 @@ func (mf *multiDifflayer) empty() bool {
// flush persists the in-memory dirty trie node into the disk if the configured
// memory threshold is reached. Note, all data must be written atomically.
func (mf *multiDifflayer) flush(db ethdb.KeyValueStore, clean *fastcache.Cache, id uint64) error {
log.Info("Start to base flush")
// Ensure the target state id is aligned with the internal counter.
head := rawdb.ReadPersistentStateID(db)
if head+mf.layers != id {
Expand Down

0 comments on commit e959def

Please sign in to comment.