diff --git a/triedb/pathdb/nodebufferlist.go b/triedb/pathdb/nodebufferlist.go index 67ca59cbc..b74fcf814 100644 --- a/triedb/pathdb/nodebufferlist.go +++ b/triedb/pathdb/nodebufferlist.go @@ -223,7 +223,7 @@ func (nf *nodebufferlist) recoverNodeBufferList(freezer *rawdb.ResettableFreezer nf.size += current.size nf.layers += current.layers } - nf.diffToBase() + nf.diffToBase(true) nf.backgroundFlush() log.Info("Succeed to recover node buffer list", "base_size", nf.base.size, "tail_state_id", nf.tail.id, @@ -676,15 +676,17 @@ func (nf *nodebufferlist) traverseReverse(cb func(*multiDifflayer) bool) { // diffToBase calls traverseReverse and merges the multiDifflayer's nodes to // base node buffer, if up to limit size and flush to disk. It is called // periodically in the background -func (nf *nodebufferlist) diffToBase() { +func (nf *nodebufferlist) diffToBase(skipCountCheck bool) { commitFunc := func(buffer *multiDifflayer) bool { if nf.base.size >= nf.base.limit { log.Debug("base node buffer need write disk immediately") return false } - if nf.count <= nf.rsevMdNum { - log.Debug("node buffer list less, waiting more difflayer to be committed") - return false + if !skipCountCheck { + if nf.count <= nf.rsevMdNum { + log.Debug("node buffer list less, waiting more difflayer to be committed") + return false + } } if buffer.block%nf.dlInMd != 0 { log.Crit("committed block number misaligned", "block", buffer.block) @@ -804,7 +806,7 @@ func (nf *nodebufferlist) loop() { if nf.isFlushing.Swap(true) { continue } - nf.diffToBase() + nf.diffToBase(false) if nf.base.size >= nf.base.limit { nf.backgroundFlush() }