Skip to content

Commit

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

release-23.2: admission: don't read tenantInfo.id after releasing the mutex
  • Loading branch information
sumeerbhola authored Nov 23, 2024
2 parents 229e5da + 135ae1c commit 1a524cd
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 @@ -750,7 +750,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 @@ -899,6 +899,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 @@ -913,7 +916,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 @@ -922,7 +925,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 1a524cd

Please sign in to comment.