Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

release-23.1: kvserver: disable eager replicate enqueue on span cfg #108812

Merged
merged 1 commit into from
Aug 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions pkg/cmd/roachtest/tests/lease_preferences.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ func runLeasePreferences(
// https://github.com/cockroachdb/cockroach/issues/105274
settings := install.MakeClusterSettings()
settings.ClusterSettings["server.span_stats.span_batch_limit"] = "4096"
settings.ClusterSettings["kv.enqueue_in_replicate_queue_on_span_config_update.enabled"] = "true"

startNodes := func(nodes ...int) {
for _, node := range nodes {
Expand Down
3 changes: 3 additions & 0 deletions pkg/kv/kvserver/client_protectedts_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ func TestProtectedTimestamps(t *testing.T) {
_, err = conn.Exec("SET CLUSTER SETTING kv.closed_timestamp.target_duration = '100ms'") // speeds up the test
require.NoError(t, err)

_, err = conn.Exec("SET CLUSTER SETTING kv.enqueue_in_replicate_queue_on_span_config_update.enabled = true") // speeds up the test
require.NoError(t, err)

const tableRangeMaxBytes = 1 << 18
_, err = conn.Exec("ALTER TABLE foo CONFIGURE ZONE USING "+
"gc.ttlseconds = 1, range_max_bytes = $1, range_min_bytes = 1<<10;", tableRangeMaxBytes)
Expand Down
11 changes: 11 additions & 0 deletions pkg/kv/kvserver/replicate_queue.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,17 @@ var MinLeaseTransferInterval = settings.RegisterDurationSetting(
settings.NonNegativeDuration,
)

// EnqueueInReplicateQueueOnSpanConfigUpdateEnabled controls whether replicas
// are enqueued into the replicate queue, following a span config update which
// affects the replica.
var EnqueueInReplicateQueueOnSpanConfigUpdateEnabled = settings.RegisterBoolSetting(
settings.SystemOnly,
"kv.enqueue_in_replicate_queue_on_span_config_update.enabled",
"controls whether replicas are enqueued into the replicate queue for "+
"processing, when a span config update occurs, which affects the replica",
false,
)

var (
metaReplicateQueueAddReplicaCount = metric.Metadata{
Name: "queue.replicate.addreplica",
Expand Down
15 changes: 12 additions & 3 deletions pkg/kv/kvserver/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -2381,6 +2381,12 @@ func (s *Store) onSpanConfigUpdate(ctx context.Context, updated roachpb.Span) {

now := s.cfg.Clock.NowAsClockTimestamp()

// The replicate queue has a relatively more expensive queue check
// (shouldQueue), because it scales with the number of stores, and
// performs more checks.
enqueueToReplicateQueueEnabled := EnqueueInReplicateQueueOnSpanConfigUpdateEnabled.Get(
&s.GetStoreConfig().Settings.SV)

s.mu.RLock()
defer s.mu.RUnlock()
if err := s.mu.replicasByKey.VisitKeyRange(ctx, sp.Key, sp.EndKey, AscendingKeyOrder,
Expand Down Expand Up @@ -2439,9 +2445,12 @@ func (s *Store) onSpanConfigUpdate(ctx context.Context, updated roachpb.Span) {
s.mergeQueue.Async(replCtx, "span config update", true /* wait */, func(ctx context.Context, h queueHelper) {
h.MaybeAdd(ctx, repl, now)
})
s.replicateQueue.Async(replCtx, "span config update", true /* wait */, func(ctx context.Context, h queueHelper) {
h.MaybeAdd(ctx, repl, now)
})

if enqueueToReplicateQueueEnabled {
s.replicateQueue.Async(replCtx, "span config update", true /* wait */, func(ctx context.Context, h queueHelper) {
h.MaybeAdd(ctx, repl, now)
})
}
return nil // more
},
); err != nil {
Expand Down