@@ -136,7 +136,7 @@ type testProcessor struct {
136
136
rac2RangeController map [roachpb.RangeID ]int
137
137
ready func (roachpb.RangeID )
138
138
}
139
- testEventCh chan func (roachpb. RangeID , * raftSchedulerShard , raftScheduleState )
139
+ testEventCh chan func (queuedRangeID , * raftSchedulerShard , raftScheduleState )
140
140
}
141
141
142
142
var _ testProcessorI = (* testProcessor )(nil )
@@ -148,7 +148,7 @@ func newTestProcessor() *testProcessor {
148
148
p .mu .raftTick = make (map [roachpb.RangeID ]int )
149
149
p .mu .rac2PiggybackedAdmitted = make (map [roachpb.RangeID ]int )
150
150
p .mu .rac2RangeController = make (map [roachpb.RangeID ]int )
151
- p .testEventCh = make (chan func (roachpb. RangeID , * raftSchedulerShard , raftScheduleState ), 10 )
151
+ p .testEventCh = make (chan func (queuedRangeID , * raftSchedulerShard , raftScheduleState ), 10 )
152
152
return p
153
153
}
154
154
@@ -198,11 +198,11 @@ func (p *testProcessor) processRACv2RangeController(_ context.Context, rangeID r
198
198
}
199
199
200
200
func (p * testProcessor ) processTestEvent (
201
- id roachpb. RangeID , ss * raftSchedulerShard , ev raftScheduleState ,
201
+ q queuedRangeID , ss * raftSchedulerShard , ev raftScheduleState ,
202
202
) {
203
203
select {
204
204
case fn := <- p .testEventCh :
205
- fn (id , ss , ev )
205
+ fn (q , ss , ev )
206
206
default :
207
207
}
208
208
}
@@ -387,45 +387,38 @@ func TestSchedulerEnqueueWhileProcessing(t *testing.T) {
387
387
388
388
// Inject code into the "middle" of event processing - after having consumed
389
389
// from the queue, but before re-checking of overlapping enqueue calls.
390
- p .testEventCh <- func (id roachpb.RangeID , ss * raftSchedulerShard , ev raftScheduleState ) {
391
- // First call into this method.
392
- //
393
- // The event calling into us must have `ev.queued` set; it was set when
394
- // enqueuing.
395
- assert .NotZero (t , ev .queued )
390
+ p .testEventCh <- func (q queuedRangeID , ss * raftSchedulerShard , ev raftScheduleState ) {
391
+ // First call into this method. The `queued` timestamp must be set.
392
+ assert .NotZero (t , q .queued )
396
393
397
394
// Even though our event is currently being processed, there is a queued
398
395
// and otherwise blank event in the scheduler state (which is how we have
399
396
// concurrent enqueue calls coalesce onto the still pending processing of
400
397
// the current event).
401
398
ss .Lock ()
402
- statePre := ss .state [id ]
399
+ statePre := ss .state [q . rangeID ]
403
400
ss .Unlock ()
404
-
405
- assert .Zero (t , statePre .queued )
406
401
assert .Equal (t , stateQueued , statePre .flags )
407
402
408
403
// Simulate a concurrent actor that enqueues the same range again.
409
404
// This will not trigger the interceptor again, since the done channel
410
405
// is closed by that time.
411
406
s .enqueue1 (stateTestIntercept , 1 )
412
407
413
- // Seeing that there is an existing "queued" event, the enqueue call below
414
- // should not populate `queued`. Instead, this will be the job of our
415
- // caller when it *actually* pushes into the queue again after fully
416
- // having handled `ev`.
408
+ // Seeing that there is an existing "queued" event, the enqueue call does
409
+ // not enqueue the rangeID again. It will be done after having handled `ev`.
417
410
ss .Lock ()
418
- statePost := ss .state [id ]
411
+ statePost := ss .state [q . rangeID ]
419
412
ss .Unlock ()
420
413
421
- assert .Zero (t , statePost .queued )
422
414
assert .Equal (t , stateQueued | stateTestIntercept , statePost .flags )
423
415
close (done )
424
416
}
425
- p .testEventCh <- func (id roachpb. RangeID , shard * raftSchedulerShard , ev raftScheduleState ) {
417
+ p .testEventCh <- func (q queuedRangeID , shard * raftSchedulerShard , ev raftScheduleState ) {
426
418
// Second call into this method, i.e. the overlappingly-enqeued event is
427
- // being processed. Check that `queued` is now set.
428
- assert .NotZero (t , ev .queued )
419
+ // being processed. Check that `queued` timestamp is set.
420
+ assert .NotZero (t , q .queued )
421
+ assert .Equal (t , stateQueued | stateTestIntercept , ev .flags )
429
422
}
430
423
s .enqueue1 (stateTestIntercept , 1 ) // will become 'ev' in the intercept
431
424
select {
0 commit comments