mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-19 19:30:44 +00:00
triedb/pathdb: only call postFlush callback on successful buffer flush
This commit is contained in:
parent
cb97c48cb6
commit
bca21b95a5
1 changed files with 7 additions and 6 deletions
|
|
@ -141,12 +141,7 @@ func (b *buffer) flush(root common.Hash, db ethdb.KeyValueStore, freezers []ethd
|
|||
// Schedule the background thread to construct the batch, which usually
|
||||
// take a few seconds.
|
||||
go func() {
|
||||
defer func() {
|
||||
if postFlush != nil {
|
||||
postFlush()
|
||||
}
|
||||
close(b.done)
|
||||
}()
|
||||
defer close(b.done)
|
||||
|
||||
// Ensure the target state id is aligned with the internal counter.
|
||||
head := rawdb.ReadPersistentStateID(db)
|
||||
|
|
@ -193,6 +188,12 @@ func (b *buffer) flush(root common.Hash, db ethdb.KeyValueStore, freezers []ethd
|
|||
// protection if try to reset the buffer here.
|
||||
// b.reset()
|
||||
log.Debug("Persisted buffer content", "nodes", nodes, "accounts", accounts, "slots", slots, "bytes", common.StorageSize(size), "elapsed", common.PrettyDuration(time.Since(start)))
|
||||
|
||||
// Only invoke postFlush callback after successful flush to avoid
|
||||
// resuming snapshot generator against non-persisted disk state.
|
||||
if postFlush != nil {
|
||||
postFlush()
|
||||
}
|
||||
}()
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue