mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-20 11:46: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
|
// Schedule the background thread to construct the batch, which usually
|
||||||
// take a few seconds.
|
// take a few seconds.
|
||||||
go func() {
|
go func() {
|
||||||
defer func() {
|
defer close(b.done)
|
||||||
if postFlush != nil {
|
|
||||||
postFlush()
|
|
||||||
}
|
|
||||||
close(b.done)
|
|
||||||
}()
|
|
||||||
|
|
||||||
// Ensure the target state id is aligned with the internal counter.
|
// Ensure the target state id is aligned with the internal counter.
|
||||||
head := rawdb.ReadPersistentStateID(db)
|
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.
|
// protection if try to reset the buffer here.
|
||||||
// b.reset()
|
// b.reset()
|
||||||
log.Debug("Persisted buffer content", "nodes", nodes, "accounts", accounts, "slots", slots, "bytes", common.StorageSize(size), "elapsed", common.PrettyDuration(time.Since(start)))
|
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