Skip to content

Commit

Permalink
stats: don't spam log with warning messages
Browse files Browse the repository at this point in the history
This commit adds a log limiter so that "buffered channel is full"
errors are printed at most once per second per node.

Fixes #36416

Release note: None
  • Loading branch information
rytaft committed Apr 2, 2019
1 parent 9e6a381 commit a6be7ed
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions pkg/sql/stats/automatic_stats.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@ var DefaultRefreshInterval = time.Minute
// any effect.
var DefaultAsOfTime = 30 * time.Second

// bufferedChanFullLogLimiter is used to minimize spamming the log with
// "buffered channel is full" errors.
var bufferedChanFullLogLimiter = log.Every(time.Second)

// Constants for automatic statistics collection.
// TODO(rytaft): Should these constants be configurable?
const (
Expand Down Expand Up @@ -357,9 +361,11 @@ func (r *Refresher) NotifyMutation(tableID sqlbase.ID, rowsAffected int) {
case r.mutations <- mutation{tableID: tableID, rowsAffected: rowsAffected}:
default:
// Don't block if there is no room in the buffered channel.
log.Warningf(context.TODO(),
"buffered channel is full. Unable to refresh stats for table %d with %d rows affected",
tableID, rowsAffected)
if bufferedChanFullLogLimiter.ShouldLog() {
log.Warningf(context.TODO(),
"buffered channel is full. Unable to refresh stats for table %d with %d rows affected",
tableID, rowsAffected)
}
}
}

Expand Down

0 comments on commit a6be7ed

Please sign in to comment.