mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-19 03:10:48 +00:00
ethdb/leveldb: add logging for database corruption recovery
This commit is contained in:
parent
3011d83e6f
commit
98155b21aa
1 changed files with 5 additions and 0 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in a new issue