Skip to content

Commit 98bb505

Browse files
craig[bot]arulajmani
andcommitted
Merge #157240
157240: base: make liveness and lease renewal fractions configurable r=arulajmani a=arulajmani Need this for the leader leases paper. Epic: none Release note: None Co-authored-by: Arul Ajmani <[email protected]>
2 parents 3efa508 + 6978d89 commit 98bb505

File tree

1 file changed

+27
-25
lines changed

1 file changed

+27
-25
lines changed

pkg/base/config.go

Lines changed: 27 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -54,31 +54,6 @@ const (
5454
// See https://github.com/cockroachdb/cockroach/issues/20310.
5555
DefaultMetricsSampleInterval = 10 * time.Second
5656

57-
// defaultRangeLeaseRenewalFraction specifies what fraction the range lease
58-
// renewal duration should be of the range lease active time. For example,
59-
// with a value of 0.2 and a lease duration of 10 seconds, leases would be
60-
// eagerly renewed 8 seconds into each lease.
61-
//
62-
// A range lease extension requires 1 RTT (Raft consensus), assuming the
63-
// leaseholder is colocated with the Raft leader, so 3 seconds should be
64-
// sufficient (see NetworkTimeout). However, on user ranges, Raft consensus
65-
// uses the DefaultClass RPC class, and is thus subject to head-of-line
66-
// blocking by other RPC traffic which can cause very high latencies under
67-
// heavy load (several seconds).
68-
defaultRangeLeaseRenewalFraction = 0.5
69-
70-
// livenessRenewalFraction specifies what fraction the node liveness renewal
71-
// duration should be of the node liveness duration. For example, with a value
72-
// of 0.2 and a liveness duration of 10 seconds, each node's liveness record
73-
// would be eagerly renewed after 8 seconds.
74-
//
75-
// A liveness record write requires 2 RTTs (RPC and Raft consensus). Assuming
76-
// a max RTT of 600ms (see NetworkTimeout), 3 seconds is enough for 2 RTTs
77-
// (2*600ms) and 1 RTO (900ms), with a 900ms buffer. The write is committed
78-
// 1/2 RTT before this. Liveness RPCs including Raft messages are sent via
79-
// SystemClass, and thus avoid head-of-line blocking by general RPC traffic.
80-
livenessRenewalFraction = 0.5
81-
8257
// DefaultDescriptorLeaseDuration is the default mean duration a
8358
// lease will be acquired for. The actual duration is jittered using
8459
// the jitter fraction. Jittering is done to prevent multiple leases
@@ -219,6 +194,33 @@ var (
219194
defaultRangeLeaseDuration = envutil.EnvOrDefaultDuration(
220195
"COCKROACH_RANGE_LEASE_DURATION", 6*time.Second)
221196

197+
// defaultRangeLeaseRenewalFraction specifies what fraction the range lease
198+
// renewal duration should be of the range lease active time. For example,
199+
// with a value of 0.2 and a lease duration of 10 seconds, leases would be
200+
// eagerly renewed 8 seconds into each lease.
201+
//
202+
// A range lease extension requires 1 RTT (Raft consensus), assuming the
203+
// leaseholder is colocated with the Raft leader, so 3 seconds should be
204+
// sufficient (see NetworkTimeout). However, on user ranges, Raft consensus
205+
// uses the DefaultClass RPC class, and is thus subject to head-of-line
206+
// blocking by other RPC traffic which can cause very high latencies under
207+
// heavy load (several seconds).
208+
defaultRangeLeaseRenewalFraction = envutil.EnvOrDefaultFloat64(
209+
"COCKROACH_RANGE_LEASE_RENEWAL_FRACTION", 0.5)
210+
211+
// livenessRenewalFraction specifies what fraction the node liveness renewal
212+
// duration should be of the node liveness duration. For example, with a value
213+
// of 0.2 and a liveness duration of 10 seconds, each node's liveness record
214+
// would be eagerly renewed after 8 seconds.
215+
//
216+
// A liveness record write requires 2 RTTs (RPC and Raft consensus). Assuming
217+
// a max RTT of 600ms (see NetworkTimeout), 3 seconds is enough for 2 RTTs
218+
// (2*600ms) and 1 RTO (900ms), with a 900ms buffer. The write is committed
219+
// 1/2 RTT before this. Liveness RPCs including Raft messages are sent via
220+
// SystemClass, and thus avoid head-of-line blocking by general RPC traffic.
221+
livenessRenewalFraction = envutil.EnvOrDefaultFloat64(
222+
"COCKROACH_LIVENESS_RENEWAL_FRACTION", 0.5)
223+
222224
// DefaultRPCHeartbeatTimeout is the default RPC heartbeat timeout. It is set
223225
// very high at 3 * NetworkTimeout for several reasons: the gRPC transport may
224226
// need to complete a dial/handshake before sending the heartbeat, the

0 commit comments

Comments
 (0)