Skip to content

Commit

Permalink
kvserver: add kv.mvcc_gc_merge.queue_interval
Browse files Browse the repository at this point in the history
Cluster setting that controls how long the MVCC GC queue waits between
processing replicas. It was previously hardcoded to 1s (which is the
default value), but changing it would've come in handy in support
incidents as a form of manual pacing of MVCC GC work (we have a similar
useful knob for the merge queue).

Release note: None
  • Loading branch information
irfansharif committed Aug 9, 2022
1 parent dcd5856 commit 4d0d98b
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions pkg/kv/kvserver/mvcc_gc_queue.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"github.com/cockroachdb/cockroach/pkg/kv/kvserver/gc"
"github.com/cockroachdb/cockroach/pkg/kv/kvserver/intentresolver"
"github.com/cockroachdb/cockroach/pkg/roachpb"
"github.com/cockroachdb/cockroach/pkg/settings"
"github.com/cockroachdb/cockroach/pkg/settings/cluster"
"github.com/cockroachdb/cockroach/pkg/spanconfig"
"github.com/cockroachdb/cockroach/pkg/storage/enginepb"
Expand All @@ -35,9 +36,9 @@ import (
)

const (
// mvccGCQueueTimerDuration is the duration between MVCC GCs of queued
// replicas.
mvccGCQueueTimerDuration = 1 * time.Second
// mvccGCQueueDefaultTimerDuration is the default duration between MVCC GCs
// of queued replicas.
mvccGCQueueDefaultTimerDuration = 1 * time.Second
// mvccGCQueueTimeout is the timeout for a single MVCC GC run.
mvccGCQueueTimeout = 10 * time.Minute
// mvccGCQueueIntentBatchTimeout is the timeout for resolving a single batch
Expand All @@ -64,6 +65,16 @@ const (
largeAbortSpanBytesThreshold = 16 * (1 << 20) // 16mb
)

// mvccGCQueueInterval is a setting that controls how long the mvcc GC queue
// waits between processing replicas.
var mvccGCQueueInterval = settings.RegisterDurationSetting(
settings.SystemOnly,
"kv.mvcc_gc_merge.queue_interval",
"how long the mvcc gc queue waits between processing replicas",
mvccGCQueueDefaultTimerDuration,
settings.NonNegativeDuration,
)

func largeAbortSpan(ms enginepb.MVCCStats) bool {
// Checks if the size of the abort span exceeds the given threshold.
// The abort span is not supposed to become that large, but it does
Expand Down Expand Up @@ -688,8 +699,8 @@ func updateStoreMetricsWithGCInfo(metrics *StoreMetrics, info gc.Info) {

// timer returns a constant duration to space out GC processing
// for successive queued replicas.
func (*mvccGCQueue) timer(_ time.Duration) time.Duration {
return mvccGCQueueTimerDuration
func (mq *mvccGCQueue) timer(_ time.Duration) time.Duration {
return mvccGCQueueInterval.Get(&mq.store.ClusterSettings().SV)
}

// purgatoryChan returns nil.
Expand Down

0 comments on commit 4d0d98b

Please sign in to comment.