From 06824348aa69d6093169cedcb6f28c97c453307f Mon Sep 17 00:00:00 2001 From: Rafi Shamim Date: Thu, 19 Dec 2024 16:56:30 +0000 Subject: [PATCH] ttljob: fix frequency of logging progress 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 --- pkg/sql/ttl/ttljob/ttljob_processor.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pkg/sql/ttl/ttljob/ttljob_processor.go b/pkg/sql/ttl/ttljob/ttljob_processor.go index 733ec1f871b3..d7dfca3cabff 100644 --- a/pkg/sql/ttl/ttljob/ttljob_processor.go +++ b/pkg/sql/ttl/ttljob/ttljob_processor.go @@ -157,6 +157,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) @@ -211,6 +212,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. @@ -247,8 +249,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 }