Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

release-24.2: ttljob: fix frequency of logging progress #137778

Merged
merged 1 commit into from
Dec 19, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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