Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

core/rawdb: only complain loudly if truncating many items #21483

Merged
merged 1 commit into from
Aug 25, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
}
karalabe marked this conversation as resolved.
Show resolved Hide resolved
log("Truncating freezer table", "items", existing, "limit", items)
if err := truncateFreezerFile(t.index, int64(items+1)*indexEntrySize); err != nil {
return err
}
Expand Down