Skip to content

Commit 8dc06bd

Browse files
committed
tenantcostclient: fix leak of CancelFunc
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. Release note: None
1 parent 8e997ca commit 8dc06bd

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)