Skip to content

Commit a884f8f

Browse files
committed
kvserver: deflake TestPromoteNonVoterInAddVoter
This test could previously fail because a lease transfer could race with a split. Without the split, the effects of the span config (that the test asserts on) will not apply. We sidestep this problem by removing the need of a split entirely -- by tuning some cluster settings to ensure that every table is on its own range to begin with. H/t to @pav-kv for the analysis on this one. Closes #155828 Closes #155747 Closes #155316 Closes #154773 Closes #134383 Release note: None
1 parent 1656a4c commit a884f8f

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

pkg/kv/kvserver/replicate_queue_test.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ import (
4141
"github.com/cockroachdb/cockroach/pkg/server/serverpb"
4242
"github.com/cockroachdb/cockroach/pkg/settings/cluster"
4343
"github.com/cockroachdb/cockroach/pkg/spanconfig"
44+
"github.com/cockroachdb/cockroach/pkg/spanconfig/spanconfigstore"
4445
"github.com/cockroachdb/cockroach/pkg/sql/catalog/bootstrap"
4546
"github.com/cockroachdb/cockroach/pkg/testutils"
4647
"github.com/cockroachdb/cockroach/pkg/testutils/skip"
@@ -2188,13 +2189,20 @@ func TestPromoteNonVoterInAddVoter(t *testing.T) {
21882189
defer testutils.StartExecTrace(t, scope.GetDirectory()).Finish(t)
21892190

21902191
ctx := context.Background()
2192+
st := cluster.MakeTestingClusterSettings()
2193+
// NB: Ensure that tables created by the test start off on their own range.
2194+
// This ensures that any span config changes made by the test don't have to
2195+
// first induce a split, which is a known source of flakiness.
2196+
spanconfigstore.StorageCoalesceAdjacentSetting.Override(ctx, &st.SV, false)
2197+
spanconfigstore.TenantCoalesceAdjacentSetting.Override(ctx, &st.SV, false)
21912198

21922199
// Create 7 stores: 3 in Region 1, 2 in Region 2, and 2 in Region 3.
21932200
const numNodes = 7
21942201
serverArgs := make(map[int]base.TestServerArgs)
21952202
regions := [numNodes]int{1, 1, 1, 2, 2, 3, 3}
21962203
for i := 0; i < numNodes; i++ {
21972204
serverArgs[i] = base.TestServerArgs{
2205+
Settings: st,
21982206
Locality: roachpb.Locality{
21992207
Tiers: []roachpb.Tier{
22002208
{

pkg/spanconfig/spanconfigstore/span_store.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ import (
1919
"github.com/cockroachdb/errors"
2020
)
2121

22-
// tenantCoalesceAdjacentSetting is a public cluster setting that
22+
// TenantCoalesceAdjacentSetting is a public cluster setting that
2323
// controls whether we coalesce adjacent ranges across all secondary
2424
// tenant keyspaces if they have the same span config.
25-
var tenantCoalesceAdjacentSetting = settings.RegisterBoolSetting(
25+
var TenantCoalesceAdjacentSetting = settings.RegisterBoolSetting(
2626
settings.SystemOnly,
2727
"spanconfig.tenant_coalesce_adjacent.enabled",
2828
`collapse adjacent ranges with the same span configs across all secondary tenant keyspaces`,
@@ -157,7 +157,7 @@ func (s *spanConfigStore) computeSplitKey(
157157
return roachpb.RKey(match.span.Key), nil
158158
}
159159
} else {
160-
if !tenantCoalesceAdjacentSetting.Get(&s.settings.SV) {
160+
if !TenantCoalesceAdjacentSetting.Get(&s.settings.SV) {
161161
return roachpb.RKey(match.span.Key), nil
162162
}
163163
}

0 commit comments

Comments
 (0)