trie: handle more batch commit errors in Database #25674 (#1118)

Co-authored-by: Amir Hossein <77993374+Kamandlou@users.noreply.github.com>
This commit is contained in:
Daniel Liu 2025-11-12 12:47:58 +08:00 committed by GitHub
parent 4bb925258d
commit d11e128322
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -677,8 +677,9 @@ func (db *Database) Commit(node common.Hash, report bool) error {
// Uncache any leftovers in the last batch
db.lock.Lock()
defer db.lock.Unlock()
batch.Replay(uncacher)
if err := batch.Replay(uncacher); err != nil {
return err
}
batch.Reset()
// Reset the storage counters and bumped metrics
@ -723,9 +724,12 @@ func (db *Database) commit(hash common.Hash, batch ethdb.Batch, uncacher *cleane
return err
}
db.lock.Lock()
batch.Replay(uncacher)
err := batch.Replay(uncacher)
batch.Reset()
db.lock.Unlock()
if err != nil {
return err
}
}
return nil
}