Skip to content

Commit 9b7bfc2

Browse files
craig[bot]yuzefovich
andcommitted
Merge #149801
149801: tenantcostclient: fix leak of CancelFunc r=yuzefovich a=yuzefovich Previously, we would never call the CancelFunc that is returned on `WithCancelOnQuiesce` that we do for each token bucket request. This would result in accumulation of CancelFuncs in the stopper, leading to a memory leak, which would only be plugged on the server shutdown. This is now fixed. Informs: #149658. Epic: None Release note: None Co-authored-by: Yahor Yuzefovich <[email protected]>
2 parents a0d944f + 8dc06bd commit 9b7bfc2

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

pkg/ccl/multitenantccl/tenantcostclient/tenant_side.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -601,8 +601,10 @@ func (c *tenantSideCostController) sendTokenBucketRequest(ctx context.Context) {
601601
c.run.lastReportedTokens = c.metrics.TotalEstimatedCPUSeconds.Count() * tokensPerCPUSecond
602602
}
603603

604-
ctx, _ = c.stopper.WithCancelOnQuiesce(ctx)
605604
err := c.stopper.RunAsyncTask(ctx, "token-bucket-request", func(ctx context.Context) {
605+
var cancel context.CancelFunc
606+
ctx, cancel = c.stopper.WithCancelOnQuiesce(ctx)
607+
defer cancel()
606608
if log.ExpensiveLogEnabled(ctx, 1) {
607609
log.Infof(ctx, "TokenBucket request: %s\n", req.String())
608610
}

0 commit comments

Comments
 (0)