Skip to content

Commit b805772

Browse files
authored
core/state: commit snapshot only if the base layer exists (#30493)
This pull request skips the state snapshot update if the base layer is not existent, eliminating the numerous warning logs after an unclean shutdown. Specifically, Geth will rewind its chain head to a historical block after unclean shutdown and state snapshot will be remained as unchanged waiting for recovery. During this period of time, the snapshot is unusable and all state updates should be ignored/skipped for state snapshot update.
1 parent 956d32d commit b805772

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

core/state/statedb.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1265,7 +1265,7 @@ func (s *StateDB) commitAndFlush(block uint64, deleteEmptyObjects bool) (*stateU
12651265
}
12661266
if !ret.empty() {
12671267
// If snapshotting is enabled, update the snapshot tree with this new version
1268-
if snap := s.db.Snapshot(); snap != nil {
1268+
if snap := s.db.Snapshot(); snap != nil && snap.Snapshot(ret.originRoot) != nil {
12691269
start := time.Now()
12701270
if err := snap.Update(ret.root, ret.originRoot, ret.destructs, ret.accounts, ret.storages); err != nil {
12711271
log.Warn("Failed to update snapshot tree", "from", ret.originRoot, "to", ret.root, "err", err)

0 commit comments

Comments
 (0)