From 04b3812821a3b307f68b51d716dbcbbd4764d84e Mon Sep 17 00:00:00 2001 From: Tobias Grieger Date: Fri, 31 Oct 2025 08:45:27 +0000 Subject: [PATCH] kvserver: deflake TestFlowControlSendQueueRangeFeed The recently added logging showed that n2 and n3 just weren't even considered for starting the rangefeed. Likely this was because the descriptors weren't gossiped yet (this was corroborated by gossip logging). Rather than waiting for specific preconditions that "likely" fix the problem for the particular version of the code, widen the scope of the retry loop to re-establish the rangefeed until it does get scheduled were it needs to for the test to succeed. Epic: none --- .../kvserver/flow_control_integration_test.go | 31 ++++++++++++------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/pkg/kv/kvserver/flow_control_integration_test.go b/pkg/kv/kvserver/flow_control_integration_test.go index 22d8a7ef9e07..4d61e50bcee0 100644 --- a/pkg/kv/kvserver/flow_control_integration_test.go +++ b/pkg/kv/kvserver/flow_control_integration_test.go @@ -3359,7 +3359,7 @@ func TestFlowControlSendQueueRangeFeed(t *testing.T) { h.resetV2TokenMetrics(ctx) h.waitForConnectedStreams(ctx, desc.RangeID, 3, 0 /* serverIdx */) - ts := tc.Server(2) + srv2 := tc.Server(2) span := desc.KeySpan().AsRawSpanWithNoLocals() ignoreValues := func(event kvcoord.RangeFeedMessage) {} @@ -3400,17 +3400,26 @@ func TestFlowControlSendQueueRangeFeed(t *testing.T) { WHERE name LIKE 'kv.rangefeed.closed_timestamp.slow_ranges.cancelled' ORDER BY name ASC; ` - - closeFeed := rangeFeed( - ctx, - ts.DistSenderI(), - span, - tc.Server(0).Clock().Now(), - ignoreValues, - kvcoord.WithRangeObserver(observer), - ) + // The rangefeed is supposed to live on n3, since that's srv2 and it is + // supposed to prefer the local replica. However, it can happen that n3 + // doesn't see itself in the gossip network yet. Retry until the rangefeed + // does get planned on n3. + var closeFeed func() + testutils.SucceedsSoon(t, func() error { + if closeFeed != nil { + closeFeed() + } + closeFeed = rangeFeed( + ctx, + srv2.DistSenderI(), + span, + tc.Server(0).Clock().Now(), + ignoreValues, + kvcoord.WithRangeObserver(observer), + ) + return checkRangeFeedNodeID(3, true /* include */) + }) defer closeFeed() - testutils.SucceedsSoon(t, func() error { return checkRangeFeedNodeID(3, true /* include */) }) h.comment(`(Rangefeed on n3)`) h.comment(`