Skip to content

Commit 5e07f09

Browse files
craig[bot]stevendannaarulajmani
committed
155616: rangefeed: add assertion that OnError is called on disconnected registration r=stevendanna a=stevendanna Epic: none Release note: None 155861: kvserver: deflake TestPromoteNonVoterInAddVoter r=arulajmani a=arulajmani 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 Co-authored-by: Steven Danna <[email protected]> Co-authored-by: Arul Ajmani <[email protected]>
3 parents b077a4e + 332301e + a884f8f commit 5e07f09

File tree

3 files changed

+13
-5
lines changed

3 files changed

+13
-5
lines changed

pkg/kv/kvserver/rangefeed/stream_manager.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,8 @@ func (sm *StreamManager) OnError(streamID int64) {
121121
func() {
122122
sm.streams.Lock()
123123
defer sm.streams.Unlock()
124-
if _, ok := sm.streams.m[streamID]; ok {
125-
// TODO(ssd): We should be able to assert we are disconnected here.
124+
if d, ok := sm.streams.m[streamID]; ok {
125+
assertTrue(d.IsDisconnected(), "OnError called on connected registration")
126126
delete(sm.streams.m, streamID)
127127
sm.metrics.ActiveMuxRangeFeed.Dec(1)
128128
}

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)