Skip to content

Commit

Permalink
kvserver: deflake test merge queue
Browse files Browse the repository at this point in the history
Previously, it was possible for ranges to spuriously merge when not
expected to in `TestMergeQueue`. Unexpected merging occurred due to the
merge delay interval being shorter than the time between test statements
- so that a merge could sneak when it shouldn't have. This was only
realistically possible running `--stress` and with a slower `deadlock`
build.

This commit updates the merge delay to be 1000 seconds, to avoid this
situation occurring.

Informs: cockroachdb#97000

Release note: None
  • Loading branch information
kvoli committed Feb 13, 2023
1 parent cdaf027 commit a55945c
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion pkg/kv/kvserver/client_merge_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4367,9 +4367,13 @@ func TestMergeQueue(t *testing.T) {
// NB: It is possible for the ranges being checked to record load
// during the test. To avoid flakiness, we set the splitByLoadStat high
// enough that any recorded load from testing won't exceed it.
// Likewise, when running under race - it is possible that if
// splitByLoadMergeDelay is small, enough time will pass in the test
// that this delay is elapsed and the ranges will merge when not
// expected to.
const splitByLoadStat = 10e9
const mergeByLoadStat = splitByLoadStat / 2 // see conservativeLoadBasedSplitThreshold
const splitByLoadMergeDelay = 500 * time.Millisecond
const splitByLoadMergeDelay = 1000 * time.Second

setSplitObjective := func(dim kvserver.LBRebalancingObjective) {
kvserver.LoadBasedRebalancingObjective.Override(ctx, sv, int64(dim))
Expand Down

0 comments on commit a55945c

Please sign in to comment.