Skip to content

Commit 824bdef

Browse files
committed
storeliveness: smear storeliveness heartbeats
Previously, heartbeat messages were sent immediately when enqueued via `EnqueueMessage`. In large clusters, many stores might all send heartbeats simultaneously at the same tick interval, causing a spike in runnable goroutines that caused issues elsewhere in the database process. This patch introduces heartbeat smearing logic that batches and smears heartbeat sends over a configurable duration using a taskpacer. The smearing logic is enabled by default via the `kv.store_liveness.heartbeat_smearing.enabled` cluster setting (defaults to true), and can be configured via `kv.store_liveness.heartbeat_smearing.refresh` (default: 10ms) and `kv.store_liveness.heartbeat_smearing.smear` (default: 1ms) settings. When enabled, messages are enqueued but not sent immediately. Instead, they wait in per-node queues until `SendAllEnqueuedMessages()` is called, which signals the coordinator. The coordinator waits briefly (`batchDuration`) to collect messages from multiple stores, then paces the signaling to each queue's `processQueue` goroutine using the pacer to spread sends over time. Fixes: #148210 Release note: None
1 parent 2b759bf commit 824bdef

File tree

6 files changed

+628
-88
lines changed

6 files changed

+628
-88
lines changed

pkg/kv/kvserver/store_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ func createTestStoreWithoutStart(
248248
supportGracePeriod := rpcContext.StoreLivenessWithdrawalGracePeriod()
249249
options := storeliveness.NewOptions(livenessInterval, heartbeatInterval, supportGracePeriod)
250250
transport, err := storeliveness.NewTransport(
251-
cfg.AmbientCtx, stopper, cfg.Clock, cfg.NodeDialer, grpcServer, drpcServer, nil, /* knobs */
251+
cfg.AmbientCtx, stopper, cfg.Clock, cfg.NodeDialer, grpcServer, drpcServer, cfg.Settings, nil, /* knobs */
252252
)
253253
require.NoError(t, err)
254254
knobs := cfg.TestingKnobs.StoreLivenessKnobs

pkg/kv/kvserver/storeliveness/BUILD.bazel

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,12 @@ go_library(
3030
"//pkg/util/envutil",
3131
"//pkg/util/hlc",
3232
"//pkg/util/log",
33+
"//pkg/util/metamorphic",
3334
"//pkg/util/metric",
3435
"//pkg/util/protoutil",
3536
"//pkg/util/stop",
3637
"//pkg/util/syncutil",
38+
"//pkg/util/taskpacer",
3739
"//pkg/util/timeutil",
3840
"@com_github_cockroachdb_errors//:errors",
3941
"@com_github_cockroachdb_redact//:redact",

0 commit comments

Comments
 (0)