mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
core/rawdb: return error if repair in readonly failed
Signed-off-by: jsvisa <delweng@gmail.com>
This commit is contained in:
parent
1f1d711c49
commit
6ffd430dd4
1 changed files with 8 additions and 4 deletions
|
|
@ -211,10 +211,11 @@ func (t *freezerTable) repair() error {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Ensure the index is a multiple of indexEntrySize bytes
|
// Ensure the index is a multiple of indexEntrySize bytes
|
||||||
if !t.readonly {
|
|
||||||
if overflow := stat.Size() % indexEntrySize; overflow != 0 {
|
if overflow := stat.Size() % indexEntrySize; overflow != 0 {
|
||||||
truncateFreezerFile(t.index, stat.Size()-overflow) // New file can't trigger this path
|
if t.readonly {
|
||||||
|
return fmt.Errorf("index file(path: %s, name: %s) size is not a multiple of %d", t.path, t.name, indexEntrySize)
|
||||||
}
|
}
|
||||||
|
truncateFreezerFile(t.index, stat.Size()-overflow) // New file can't trigger this path
|
||||||
}
|
}
|
||||||
// Retrieve the file sizes and prepare for truncation
|
// Retrieve the file sizes and prepare for truncation
|
||||||
if stat, err = t.index.Stat(); err != nil {
|
if stat, err = t.index.Stat(); err != nil {
|
||||||
|
|
@ -271,7 +272,10 @@ func (t *freezerTable) repair() error {
|
||||||
|
|
||||||
// Keep truncating both files until they come in sync
|
// Keep truncating both files until they come in sync
|
||||||
contentExp = int64(lastIndex.offset)
|
contentExp = int64(lastIndex.offset)
|
||||||
for !t.readonly && contentExp != contentSize {
|
for contentExp != contentSize {
|
||||||
|
if t.readonly {
|
||||||
|
return fmt.Errorf("freezer table(path: %s, name: %s num: %d) is corrupted", t.path, t.name, lastIndex.filenum)
|
||||||
|
}
|
||||||
verbose = true
|
verbose = true
|
||||||
// Truncate the head file to the last offset pointer
|
// Truncate the head file to the last offset pointer
|
||||||
if contentExp < contentSize {
|
if contentExp < contentSize {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue