@@ -13,6 +13,7 @@ import (
1313 "sync/atomic"
1414 "time"
1515
16+ "github.com/cockroachdb/cockroach/pkg/keys"
1617 "github.com/cockroachdb/cockroach/pkg/kv"
1718 "github.com/cockroachdb/cockroach/pkg/kv/kvpb"
1819 "github.com/cockroachdb/cockroach/pkg/kv/kvserver/gc"
@@ -123,16 +124,6 @@ var EnqueueInMvccGCQueueOnSpanConfigUpdateEnabled = settings.RegisterBoolSetting
123124 false ,
124125)
125126
126- // See https://github.com/cockroachdb/cockroach/pull/143122.
127- var mvccGCQueueFullyEnableAC = settings .RegisterBoolSetting (
128- settings .SystemOnly ,
129- "kv.mvcc_gc.queue_kv_admission_control.enabled" ,
130- "when true, MVCC GC queue operations are subject to store admission control. If set to false, " +
131- "since store admission control will be disabled, replication flow control will also be effectively disabled. " +
132- "This setting does not affect CPU admission control." ,
133- true ,
134- )
135-
136127func largeAbortSpan (ms enginepb.MVCCStats ) bool {
137128 // Checks if the size of the abort span exceeds the given threshold.
138129 // The abort span is not supposed to become that large, but it does
@@ -594,6 +585,11 @@ func (r *replicaGCer) template() kvpb.GCRequest {
594585 desc := r .repl .Desc ()
595586 var template kvpb.GCRequest
596587 template .Key = desc .StartKey .AsRawKey ()
588+ if r .repl .RangeID == 1 {
589+ // r1 should really start at LocalMax but it starts "officially" at KeyMin
590+ // which is not addressable.
591+ template .Key = keys .LocalMax
592+ }
597593 template .EndKey = desc .EndKey .AsRawKey ()
598594
599595 return template
@@ -603,34 +599,13 @@ func (r *replicaGCer) send(ctx context.Context, req kvpb.GCRequest) error {
603599 n := atomic .AddInt32 (& r .count , 1 )
604600 log .Eventf (ctx , "sending batch %d (%d keys, %d rangekeys)" , n , len (req .Keys ), len (req .RangeKeys ))
605601
606- ba := & kvpb.BatchRequest {}
607- // Technically not needed since we're talking directly to the Replica.
608- ba .RangeID = r .repl .Desc ().RangeID
609- ba .Timestamp = r .repl .Clock ().Now ()
610- ba .Add (& req )
611- // Since we are talking directly to the replica, we need to explicitly do
612- // admission control here, as we are bypassing server.Node.
613- var admissionHandle kvadmission.Handle
614- if r .admissionController != nil {
615- ba .AdmissionHeader = gcAdmissionHeader (r .repl .ClusterSettings ())
616- ba .Replica .StoreID = r .storeID
617- var err error
618- admissionHandle , err = r .admissionController .AdmitKVWork (ctx , roachpb .SystemTenantID , ba )
619- if err != nil {
620- return err
621- }
622- if mvccGCQueueFullyEnableAC .Get (& r .repl .ClusterSettings ().SV ) {
623- ctx = admissionHandle .AnnotateCtx (ctx )
624- }
625- }
626- _ , writeBytes , pErr := r .repl .SendWithWriteBytes (ctx , ba )
627- defer writeBytes .Release ()
628- if r .admissionController != nil {
629- r .admissionController .AdmittedKVWorkDone (admissionHandle , writeBytes )
630- }
631- if pErr != nil {
632- log .VErrEventf (ctx , 2 , "%v" , pErr .String ())
633- return pErr .GoError ()
602+ var b kv.Batch
603+ b .AddRawRequest (& req )
604+ b .AdmissionHeader = gcAdmissionHeader (r .repl .ClusterSettings ())
605+
606+ if err := r .repl .store .cfg .DB .Run (ctx , & b ); err != nil {
607+ log .Infof (ctx , "%s" , err )
608+ return err
634609 }
635610 return nil
636611}
0 commit comments