Skip to content

Commit

Permalink
ttljob: fix frequency of logging progress
Browse files Browse the repository at this point in the history
The progress is supposed to be logged periodically, but the logic to
check when the last log occurred was broken. This fixed it by resetting
the count of spans processed since the last log.

Release note: None
  • Loading branch information
rafiss committed Dec 19, 2024
1 parent 2bfb782 commit 9c37e17
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion pkg/sql/ttl/ttljob/ttljob_processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ func (t *ttlProcessor) work(ctx context.Context) error {
}
var rowsDeletedSoFar atomic.Int64
var spansProccessedSoFar atomic.Int64
var spansProccessedSinceLastLog atomic.Int64

// Log progress approximately every 1% of spans processed.
updateEvery := max(1, processorSpanCount/100)
Expand Down Expand Up @@ -221,6 +222,7 @@ func (t *ttlProcessor) work(ctx context.Context) error {
// add before returning err in case of partial success
rowsDeletedSoFar.Add(spanRowCount)
spansProccessedSoFar.Add(1)
spansProccessedSinceLastLog.Add(1)
if err != nil {
// Continue until channel is fully read.
// Otherwise, the keys input will be blocked.
Expand Down Expand Up @@ -257,8 +259,10 @@ func (t *ttlProcessor) work(ctx context.Context) error {
// If the span has no rows, we still need to increment the processed
// count.
spansProccessedSoFar.Add(1)
spansProccessedSinceLastLog.Add(1)
}
if spansProccessedSoFar.Load() >= updateEvery {
if spansProccessedSinceLastLog.Load() >= updateEvery {
spansProccessedSinceLastLog.Store(0)
if err := logProgress(); err != nil {
return err
}
Expand Down

0 comments on commit 9c37e17

Please sign in to comment.