Skip to content

Commit 1fe4a55

Browse files
committed
catalog/lease: use WithTenantCostControlExemption for some tasks
These are background tasks that we should not attribute to the user. Release note: None
1 parent af1c770 commit 1fe4a55

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

pkg/sql/catalog/lease/lease.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import (
2222
"github.com/cockroachdb/cockroach/pkg/kv"
2323
"github.com/cockroachdb/cockroach/pkg/kv/kvclient/rangefeed"
2424
"github.com/cockroachdb/cockroach/pkg/kv/kvpb"
25+
"github.com/cockroachdb/cockroach/pkg/multitenant"
2526
"github.com/cockroachdb/cockroach/pkg/roachpb"
2627
"github.com/cockroachdb/cockroach/pkg/server/settingswatcher"
2728
"github.com/cockroachdb/cockroach/pkg/settings"
@@ -1584,6 +1585,7 @@ func (m *Manager) findDescriptorState(id descpb.ID, create bool) *descriptorStat
15841585
// rangefeeds. This function must be passed a non-nil gossip if
15851586
// RangefeedLeases is not active.
15861587
func (m *Manager) StartRefreshLeasesTask(ctx context.Context, s *stop.Stopper, db *kv.DB) {
1588+
ctx = multitenant.WithTenantCostControlExemption(ctx)
15871589
m.mu.Lock()
15881590
defer m.mu.Unlock()
15891591
defer close(m.waitForInit)
@@ -1852,6 +1854,7 @@ func (m *Manager) checkRangeFeedStatus(ctx context.Context) (forceRefresh bool)
18521854
// range feed progress / recovery, and supporting legacy expiry
18531855
// based leases.
18541856
func (m *Manager) RunBackgroundLeasingTask(ctx context.Context) {
1857+
ctx = multitenant.WithTenantCostControlExemption(ctx)
18551858
// The refresh loop is used to clean up leases that have expired (because of
18561859
// a new version), and track range feed availability. This will run based on
18571860
// the lease duration, but will still periodically run if the duration is zero.
@@ -2098,6 +2101,8 @@ func (m *Manager) DeleteOrphanedLeases(
20982101
// Run as async worker to prevent blocking the main server Start method.
20992102
// Exit after releasing all the orphaned leases.
21002103
newCtx := m.ambientCtx.AnnotateCtx(context.Background())
2104+
newCtx = multitenant.WithTenantCostControlExemption(newCtx)
2105+
21012106
// AddTags and not WithTags, so that we combine the tags with those
21022107
// filled by AnnotateCtx.
21032108
newCtx = logtags.AddTags(newCtx, logtags.FromContext(ctx))

0 commit comments

Comments
 (0)