Skip to content

Commit

Permalink
Merge pull request #21483 from karalabe/freezer-truncate-silent
Browse files Browse the repository at this point in the history
core/rawdb: only complain loudly if truncating many items
  • Loading branch information
karalabe authored Aug 25, 2020
2 parents 7b5107b + 5655dce commit d13b8e5
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions core/rawdb/freezer_table.go
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,8 @@ func (t *freezerTable) truncate(items uint64) error {
defer t.lock.Unlock()

// If our item count is correct, don't do anything
if atomic.LoadUint64(&t.items) <= items {
existing := atomic.LoadUint64(&t.items)
if existing <= items {
return nil
}
// We need to truncate, save the old size for metrics tracking
Expand All @@ -339,7 +340,11 @@ func (t *freezerTable) truncate(items uint64) error {
return err
}
// Something's out of sync, truncate the table's offset index
t.logger.Warn("Truncating freezer table", "items", t.items, "limit", items)
log := t.logger.Debug
if existing > items+1 {
log = t.logger.Warn // Only loud warn if we delete multiple items
}
log("Truncating freezer table", "items", existing, "limit", items)
if err := truncateFreezerFile(t.index, int64(items+1)*indexEntrySize); err != nil {
return err
}
Expand Down

0 comments on commit d13b8e5

Please sign in to comment.