Skip to content

Commit a14544a

Browse files
craig[bot]tbg
andcommitted
Merge #143122
143122: kvserver: actually subject MVCC GC to IO admission control r=tbg a=tbg MVCC GC sends BatchRequests directly to `(*Replica).SendWithWriteBytes`. Since admission control hooks live at a higher level `(*Node).batchInternal`, MVCC GC duplicated the relevant hooks in `(*replicaGCer).send`. This duplication was incomplete: the context passed to `SendWithWriteBytes` needed to be "annotated" with the `admissionHandle` - essentially, this puts the admission metadata into the context, so that it can be picked up at Raft proposal time to encode the admission control policy into the replicated log entry. Because this annotation was missing, the log entries were encoded as not being subject to admission control at all. I diagnosed this all via hacky printf debugging on `release-23.2`. Clearly we have no test coverage, or this wouldn't have been undetected for so long. Touches https://github.com/cockroachlabs/support/issues/3213. Epic: none Release note (bug fix): MVCC garbage collection is now fully subject to IO admission control. Previously, it was possible for MVCC GC to cause store overload (such as LSM inversion) when a large amounts of data would become eligible for garbage collection. Co-authored-by: Tobias Grieger <[email protected]>
2 parents ce3c356 + 9380379 commit a14544a

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

pkg/kv/kvserver/mvcc_gc_queue.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,16 @@ var EnqueueInMvccGCQueueOnSpanConfigUpdateEnabled = settings.RegisterBoolSetting
123123
false,
124124
)
125125

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+
126136
func largeAbortSpan(ms enginepb.MVCCStats) bool {
127137
// Checks if the size of the abort span exceeds the given threshold.
128138
// The abort span is not supposed to become that large, but it does
@@ -609,6 +619,9 @@ func (r *replicaGCer) send(ctx context.Context, req kvpb.GCRequest) error {
609619
if err != nil {
610620
return err
611621
}
622+
if mvccGCQueueFullyEnableAC.Get(&r.repl.ClusterSettings().SV) {
623+
ctx = admissionHandle.AnnotateCtx(ctx)
624+
}
612625
}
613626
_, writeBytes, pErr := r.repl.SendWithWriteBytes(ctx, ba)
614627
defer writeBytes.Release()

0 commit comments

Comments
 (0)