core/state/pruner: handle batch write errors in pruning

This commit is contained in:
mk0walsk 2026-05-15 22:18:24 +08:00
parent 8a0223e8da
commit 8042c83333

View file

@ -171,7 +171,10 @@ func prune(snaptree *snapshot.Tree, root common.Hash, maindb ethdb.Database, sta
// Recreate the iterator after every batch commit in order
// to allow the underlying compactor to delete the entries.
if batch.ValueSize() >= ethdb.IdealBatchSize {
batch.Write()
if err := batch.Write(); err != nil {
iter.Release()
return err
}
batch.Reset()
iter.Release()
@ -180,7 +183,10 @@ func prune(snaptree *snapshot.Tree, root common.Hash, maindb ethdb.Database, sta
}
}
if batch.ValueSize() > 0 {
batch.Write()
if err := batch.Write(); err != nil {
iter.Release()
return err
}
batch.Reset()
}
iter.Release()