Skip to content

Commit

Permalink
Merge pull request #135782 from cockroachdb/blathers/backport-release…
Browse files Browse the repository at this point in the history
…-24.2-135742

release-24.2: admission: don't read tenantInfo.id after releasing the mutex
  • Loading branch information
sumeerbhola authored Nov 23, 2024
2 parents cff66e2 + f319f60 commit ec23781
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions pkg/util/admission/work_queue.go
Original file line number Diff line number Diff line change
Expand Up @@ -749,7 +749,7 @@ func (q *WorkQueue) Admit(ctx context.Context, info WorkInfo) (enabled bool, err
q.mu.Unlock()

log.Infof(ctx, "async-path: len(waiting-work)=%d: enqueued t%d pri=%s r%s origin=n%s log-position=%s ingested=%t",
queueLen, tenant.id, info.Priority,
queueLen, tenantID, info.Priority,
info.ReplicatedWorkInfo.RangeID,
info.ReplicatedWorkInfo.Origin,
info.ReplicatedWorkInfo.LogPosition,
Expand Down Expand Up @@ -898,6 +898,9 @@ func (q *WorkQueue) granted(grantChainID grantChainID) int64 {
// releasing Admit can notice that item is no longer in the heap and call
// releaseWaitingWork to return item to the waitingWorkPool.
requestedCount := item.requestedCount
// Cannot read tenant after release q.mu, since tenant may get GC'd and
// reused.
tenantID := tenant.id
q.mu.Unlock()

if !item.replicated.Enabled {
Expand All @@ -912,7 +915,7 @@ func (q *WorkQueue) granted(grantChainID grantChainID) int64 {
q.mu.Unlock()

log.Infof(q.ambientCtx, "async-path: len(waiting-work)=%d dequeued t%d pri=%s r%s origin=n%s log-position=%s ingested=%t",
queueLen, tenant.id, item.priority,
queueLen, tenantID, item.priority,
item.replicated.RangeID,
item.replicated.Origin,
item.replicated.LogPosition,
Expand All @@ -921,7 +924,7 @@ func (q *WorkQueue) granted(grantChainID grantChainID) int64 {
}
defer releaseWaitingWork(item)
q.onAdmittedReplicatedWork.admittedReplicatedWork(
roachpb.MustMakeTenantID(tenant.id),
roachpb.MustMakeTenantID(tenantID),
item.priority,
item.replicated,
item.requestedCount,
Expand Down

0 comments on commit ec23781

Please sign in to comment.