Skip to content

Commit

Permalink
kv,admission: add missing admission headers
Browse files Browse the repository at this point in the history
This patch adds missing admission headers in a couple of places:
`txn_interceptor_heartbeater` and `replica_range_lease`. Batch requests
coming from these code paths are expected to bypass AC. Empty admission
headers were accomplishing the same goal but this makes it more clear at
what the intention is.

Informs #112680

Release note: None
  • Loading branch information
aadityasondhi committed Dec 12, 2023
1 parent b879209 commit 4c26a9b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
7 changes: 7 additions & 0 deletions pkg/kv/kvclient/kvcoord/txn_interceptor_heartbeater.go
Original file line number Diff line number Diff line change
Expand Up @@ -525,6 +525,13 @@ func (h *txnHeartbeater) abortTxnAsyncLocked(ctx context.Context) {
// concurrent requests from failing to notice the transaction was aborted.
Poison: true,
})
// NB: Setting `Source: kvpb.AdmissionHeader_OTHER` means this request will
// bypass AC.
ba.AdmissionHeader = kvpb.AdmissionHeader{
Priority: txn.AdmissionPriority,
CreateTime: timeutil.Now().UnixNano(),
Source: kvpb.AdmissionHeader_OTHER,
}

const taskName = "txnHeartbeater: aborting txn"
log.VEventf(ctx, 2, "async abort for txn: %s", txn)
Expand Down
8 changes: 8 additions & 0 deletions pkg/kv/kvserver/replica_range_lease.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ import (
"github.com/cockroachdb/cockroach/pkg/roachpb"
"github.com/cockroachdb/cockroach/pkg/settings"
"github.com/cockroachdb/cockroach/pkg/util"
"github.com/cockroachdb/cockroach/pkg/util/admission/admissionpb"
"github.com/cockroachdb/cockroach/pkg/util/envutil"
"github.com/cockroachdb/cockroach/pkg/util/growstack"
"github.com/cockroachdb/cockroach/pkg/util/hlc"
Expand Down Expand Up @@ -571,6 +572,13 @@ func (p *pendingLeaseRequest) requestLease(
// lease when the range is unavailable results in, essentially, giving
// up on the lease and thus worsening the situation.
ba.Add(leaseReq)
// NB: Setting `Source: kvpb.AdmissionHeader_OTHER` means this request will
// bypass AC.
ba.AdmissionHeader = kvpb.AdmissionHeader{
Priority: int32(admissionpb.NormalPri),
CreateTime: timeutil.Now().UnixNano(),
Source: kvpb.AdmissionHeader_OTHER,
}
_, pErr := p.repl.Send(ctx, ba)
return pErr.GoError()
}
Expand Down

0 comments on commit 4c26a9b

Please sign in to comment.