Skip to content

Commit

Permalink
Improve logging
Browse files Browse the repository at this point in the history
  • Loading branch information
reductionista committed Oct 1, 2024
1 parent b7f8797 commit 56ab0a0
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions core/chains/evm/logpoller/log_poller.go
Original file line number Diff line number Diff line change
Expand Up @@ -668,33 +668,41 @@ func (lp *logPoller) backgroundWorkerRun() {
case <-ctx.Done():
return
case <-blockPruneTick:
lp.lggr.Infow("pruning old blocks")
blockPruneTick = tickWithDefaultJitter(blockPruneInterval)
if allRemoved, err := lp.PruneOldBlocks(ctx); err != nil {
lp.lggr.Errorw("Unable to prune old blocks", "err", err)
lp.lggr.Errorw("unable to prune old blocks", "err", err)
} else if !allRemoved {
// Tick faster when cleanup can't keep up with the pace of new blocks
blockPruneTick = tickWithDefaultJitter(blockPruneShortInterval)
lp.lggr.Warnw("reached page limit while pruning old blocks")
} else {
lp.lggr.Debugw("finished pruning old blocks")
}
case <-logPruneTick:
logPruneTick = tickWithDefaultJitter(logPruneInterval)
lp.lggr.Infof("Pruning expired logs")
lp.lggr.Infof("pruning expired logs")
if allRemoved, err := lp.PruneExpiredLogs(ctx); err != nil {
lp.lggr.Errorw("Unable to prune expired logs", "err", err)
lp.lggr.Errorw("unable to prune expired logs", "err", err)
} else if !allRemoved {
lp.lggr.Warnw("reached page limit while pruning expired logs")
// Tick faster when cleanup can't keep up with the pace of new logs
logPruneTick = tickWithDefaultJitter(logPruneShortInterval)
} else if successfulExpiredLogPrunes == 4 {
} else if successfulExpiredLogPrunes >= 4 {
// Only prune unmatched logs if we've successfully pruned all expired logs at least 20 times
// since the last time unmatched logs were pruned
lp.lggr.Infof("Pruning unmatched logs")
lp.lggr.Infof("finished pruning expired logs: pruning unmatched logs")
if allRemoved, err := lp.PruneUnmatchedLogs(ctx); err != nil {
lp.lggr.Errorw("Unable to prune unmatched logs", "err", err)
lp.lggr.Errorw("unable to prune unmatched logs", "err", err)
} else if !allRemoved {
lp.lggr.Warnw("reached page limit while pruning unmatched logs")
logPruneTick = tickWithDefaultJitter(logPruneShortInterval)
} else {
lp.lggr.Debugw("finished pruning unmatched logs")
successfulExpiredLogPrunes = 0
}
} else {
lp.lggr.Debugw("finished pruning expired logs")
successfulExpiredLogPrunes++
}
}
Expand Down

0 comments on commit 56ab0a0

Please sign in to comment.