Skip to content

Commit 055dacb

Browse files
committed
sql: fix TestRelocateNonVoters flake by speeding up allocator intervals
The test was failing due to race conditions between allocator operations and manual relocate commands. Set allocator intervals to 100ms to allow faster recovery from inconsistent replica states. Fixes #150993 Release note: None Epic: None
1 parent 9668b08 commit 055dacb

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

pkg/sql/BUILD.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -796,6 +796,7 @@ go_test(
796796
"//pkg/kv/kvclient/rangefeed",
797797
"//pkg/kv/kvpb",
798798
"//pkg/kv/kvserver",
799+
"//pkg/kv/kvserver/allocator",
799800
"//pkg/kv/kvserver/concurrency/isolation",
800801
"//pkg/kv/kvserver/kvserverbase",
801802
"//pkg/kv/kvserver/protectedts",

pkg/sql/multitenant_admin_function_test.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,12 @@ import (
1313
"strconv"
1414
"strings"
1515
"testing"
16+
"time"
1617

1718
"github.com/cockroachdb/cockroach/pkg/base"
1819
"github.com/cockroachdb/cockroach/pkg/config/zonepb"
1920
"github.com/cockroachdb/cockroach/pkg/kv/kvserver"
21+
"github.com/cockroachdb/cockroach/pkg/kv/kvserver/allocator"
2022
"github.com/cockroachdb/cockroach/pkg/kv/kvserver/kvserverbase"
2123
"github.com/cockroachdb/cockroach/pkg/multitenant/tenantcapabilitiespb"
2224
"github.com/cockroachdb/cockroach/pkg/roachpb"
@@ -58,6 +60,13 @@ func createTestClusterArgs(ctx context.Context, numReplicas, numVoters int32) ba
5860
clusterSettings := cluster.MakeTestingClusterSettings()
5961
kvserver.LoadBasedRebalancingMode.Override(ctx, &clusterSettings.SV, kvserver.LBRebalancingOff)
6062
kvserverbase.MergeQueueEnabled.Override(ctx, &clusterSettings.SV, false)
63+
64+
// Set allocator intervals to scan faster to help with recovery from race
65+
// conditions between allocator and manual relocate operations.
66+
allocator.LoadBasedRebalanceInterval.Override(ctx, &clusterSettings.SV, 100*time.Millisecond)
67+
kvserver.MinLeaseTransferInterval.Override(ctx, &clusterSettings.SV, 100*time.Millisecond)
68+
kvserver.MinIOOverloadLeaseShedInterval.Override(ctx, &clusterSettings.SV, 100*time.Millisecond)
69+
6170
return base.TestClusterArgs{
6271
ServerArgs: base.TestServerArgs{
6372
Settings: clusterSettings,

0 commit comments

Comments
 (0)