Skip to content

Commit 5655dce

Browse files
committed
core/rawdb: only complain loudly if truncating many items
1 parent 7b5107b commit 5655dce

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

core/rawdb/freezer_table.go

+7-2
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,8 @@ func (t *freezerTable) truncate(items uint64) error {
330330
defer t.lock.Unlock()
331331

332332
// If our item count is correct, don't do anything
333-
if atomic.LoadUint64(&t.items) <= items {
333+
existing := atomic.LoadUint64(&t.items)
334+
if existing <= items {
334335
return nil
335336
}
336337
// We need to truncate, save the old size for metrics tracking
@@ -339,7 +340,11 @@ func (t *freezerTable) truncate(items uint64) error {
339340
return err
340341
}
341342
// Something's out of sync, truncate the table's offset index
342-
t.logger.Warn("Truncating freezer table", "items", t.items, "limit", items)
343+
log := t.logger.Debug
344+
if existing > items+1 {
345+
log = t.logger.Warn // Only loud warn if we delete multiple items
346+
}
347+
log("Truncating freezer table", "items", existing, "limit", items)
343348
if err := truncateFreezerFile(t.index, int64(items+1)*indexEntrySize); err != nil {
344349
return err
345350
}

0 commit comments

Comments
 (0)