From a0bbdd9f30c2cf5e320e85a0b14ed23d5672c82b Mon Sep 17 00:00:00 2001 From: Amir Hossein <77993374+Kamandlou@users.noreply.github.com> Date: Fri, 16 Sep 2022 02:05:53 +0430 Subject: [PATCH] trie: handle more batch commit errors in Database (#25674) --- trie/database.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/trie/database.go b/trie/database.go index 79de0ed65c48..30120570ab57 100644 --- a/trie/database.go +++ b/trie/database.go @@ -662,8 +662,9 @@ func (db *Database) Commit(node common.Hash, report bool, callback func(common.H // 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 @@ -711,9 +712,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 }