Skip to content

Commit

Permalink
Merge #73639
Browse files Browse the repository at this point in the history
73639: kvserver: introduce sCfg.SlowReplicationThreshold r=erikgrinaker a=tbg

This defaults to `base.SlowRequestThreshold` but is customizable, which
will be helpful for testing #71806.

Release note: None


Co-authored-by: Tobias Grieger <[email protected]>
  • Loading branch information
craig[bot] and tbg committed Dec 10, 2021
2 parents 1d7f06b + f955c65 commit 4422323
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
3 changes: 1 addition & 2 deletions pkg/kv/kvserver/replica_write.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import (
"context"
"time"

"github.com/cockroachdb/cockroach/pkg/base"
"github.com/cockroachdb/cockroach/pkg/kv"
"github.com/cockroachdb/cockroach/pkg/kv/kvserver/batcheval"
"github.com/cockroachdb/cockroach/pkg/kv/kvserver/batcheval/result"
Expand Down Expand Up @@ -176,7 +175,7 @@ func (r *Replica) executeWriteBatch(
startPropTime := timeutil.Now()
slowTimer := timeutil.NewTimer()
defer slowTimer.Stop()
slowTimer.Reset(base.SlowRequestThreshold)
slowTimer.Reset(r.store.cfg.SlowReplicationThreshold)
// NOTE: this defer was moved from a case in the select statement to here
// because escape analysis does a better job avoiding allocations to the
// heap when defers are unconditional. When this was in the slowTimer select
Expand Down
7 changes: 7 additions & 0 deletions pkg/kv/kvserver/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -1016,6 +1016,10 @@ type StoreConfig struct {

// KVAdmissionController is an optional field used for admission control.
KVAdmissionController KVAdmissionController

// SlowReplicationThreshold is the duration after which an in-flight proposal
// is tracked in the requests.slow.raft metric.
SlowReplicationThreshold time.Duration
}

// ConsistencyTestingKnobs is a BatchEvalTestingKnobs struct used to control the
Expand Down Expand Up @@ -1062,6 +1066,9 @@ func (sc *StoreConfig) SetDefaults() {
if sc.TestingKnobs.GossipWhenCapacityDeltaExceedsFraction == 0 {
sc.TestingKnobs.GossipWhenCapacityDeltaExceedsFraction = defaultGossipWhenCapacityDeltaExceedsFraction
}
if sc.SlowReplicationThreshold == 0 {
sc.SlowReplicationThreshold = base.SlowRequestThreshold
}
}

// GetStoreConfig exposes the config used for this store.
Expand Down

0 comments on commit 4422323

Please sign in to comment.