Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
108777: metricspoller: avoid forever-growing context chain r=dt,knz,miretskiy a=stevendanna

logtags.AddTag calls context.WithValue which creates a new context. Further, here we were re-assigning this new context to the original context passed to the Resume function. As a result, I believe that we were ending up with a constantly growing chain of contexts.

We believe this is the cause of slowly growing CPU usage.

Epic: None

Release note (bug fix): Fix bug that could cause CPU usage to increase over time.

Co-authored-by: Steven Danna <[email protected]>
  • Loading branch information
craig[bot] and stevendanna committed Aug 15, 2023
2 parents 8ebc6f1 + c090383 commit 7c51462
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions pkg/jobs/metricspoller/poller.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,7 @@ func (mp *metricsPoller) Resume(ctx context.Context, execCtx interface{}) error
defer t.Stop()

runTask := func(name string, task func(ctx context.Context, execCtx sql.JobExecContext) error) error {
ctx = logtags.AddTag(ctx, "task", name)
return task(ctx, exec)
return task(logtags.AddTag(ctx, "task", name), exec)
}

for {
Expand Down

0 comments on commit 7c51462

Please sign in to comment.