Skip to content

Commit e2a881b

Browse files
committed
kvserver/rangefeed: deflake TestUnbufferedRegOnCatchUpSwitchOver/disconnect_after_runOutputLoop
This test was using the capacity of the catchUpBuf to decide how many post-catch-up events need to be delivered. This is a problem because the the output loop might have already finished the catchup scan, flushed its empty catch up buffer, set the buffer to nil (0 cap), and exited before we ever even observe the cap of the catchup buffer. One note is that this test is a bit odd because depending on the speed of the catchup up scan, the events might come to us via the catchup buffer publish or directly. Fixes #152960 Release note: None
1 parent eb8c0d9 commit e2a881b

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

pkg/kv/kvserver/rangefeed/unbuffered_registration_test.go

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -359,19 +359,17 @@ func TestUnbufferedRegOnCatchUpSwitchOver(t *testing.T) {
359359
defer wg.Done()
360360
r.runOutputLoop(ctx, 0)
361361
}()
362-
capOfBuf := cap(r.mu.catchUpBuf)
363-
r.publish(ctx, ev1, &SharedBudgetAllocation{refCount: 1})
364-
r.publish(ctx, ev2, &SharedBudgetAllocation{refCount: 1})
365-
r.publish(ctx, ev3, &SharedBudgetAllocation{refCount: 1})
366-
r.publish(ctx, ev4, &SharedBudgetAllocation{refCount: 1})
367-
r.publish(ctx, ev5, &SharedBudgetAllocation{refCount: 1})
362+
postCatchUpEvents := []*kvpb.RangeFeedEvent{ev1, ev2, ev3, ev4, ev5}
363+
for _, ev := range postCatchUpEvents {
364+
r.publish(ctx, ev, &SharedBudgetAllocation{refCount: 1})
365+
}
368366
catchUpEvents := expEvents(false)
369367
wg.Wait()
370368

371369
require.False(t, r.getOverflowed())
372370
require.Nil(t, r.getBuf())
373-
s.waitForEventCount(t, capOfBuf+len(catchUpEvents))
371+
s.waitForEventCount(t, len(postCatchUpEvents)+len(catchUpEvents))
374372
require.Equal(t,
375-
[]*kvpb.RangeFeedEvent{ev1, ev2, ev3, ev4, ev5}, s.mu.events[len(catchUpEvents):])
373+
postCatchUpEvents, s.mu.events[len(catchUpEvents):])
376374
})
377375
}

0 commit comments

Comments
 (0)