ethdb/leveldb: add logging for database corruption recovery

This commit is contained in:
Vicky 2026-02-11 22:15:18 +08:00
parent 3011d83e6f
commit 98155b21aa

View file

@ -122,7 +122,12 @@ func NewCustom(file string, namespace string, customize func(options *opt.Option
// Open the db and recover any potential corruptions
db, err := leveldb.OpenFile(file, options)
if _, corrupted := err.(*lerrors.ErrCorrupted); corrupted {
logger.Error("Database corrupted, attempting recovery", "error", err)
db, err = leveldb.RecoverFile(file, nil)
if err != nil {
return nil, fmt.Errorf("database recovery failed: %w", err)
}
logger.Warn("Database recovery succeeded")
}
if err != nil {
return nil, err