Skip to content

Commit

Permalink
fix: ignore truncation target range as unclean shutdown happens
Browse files Browse the repository at this point in the history
  • Loading branch information
krish-nr committed Jul 24, 2024
1 parent 887404f commit d6fbb0e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion trie/triedb/pathdb/history.go
Original file line number Diff line number Diff line change
Expand Up @@ -619,7 +619,8 @@ func truncateFromTail(db ethdb.Batcher, freezer *rawdb.ResettableFreezer, ntail
}
// Ensure that the truncation target falls within the specified range.
if otail > ntail || ntail > ohead {
return 0, fmt.Errorf("out of range, tail: %d, head: %d, target: %d", otail, ohead, ntail)
log.Warn("truncate from tail out of range", "tail:", otail, "head:", ohead, "target:", ntail)
return 0, nil
}
// Short circuit if nothing to truncate.
if otail == ntail {
Expand Down
4 changes: 2 additions & 2 deletions trie/triedb/pathdb/history_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -252,8 +252,8 @@ func TestTruncateOutOfRange(t *testing.T) {
{0, head + 1, fmt.Errorf("out of range, tail: %d, head: %d, target: %d", tail, head, head+1)},
{0, tail - 1, fmt.Errorf("out of range, tail: %d, head: %d, target: %d", tail, head, tail-1)},
{1, tail, nil}, // nothing to delete
{1, head + 1, fmt.Errorf("out of range, tail: %d, head: %d, target: %d", tail, head, head+1)},
{1, tail - 1, fmt.Errorf("out of range, tail: %d, head: %d, target: %d", tail, head, tail-1)},
{1, head + 1, nil},
{1, tail - 1, nil},
}
for _, c := range cases {
var gotErr error
Expand Down

0 comments on commit d6fbb0e

Please sign in to comment.