@@ -143,7 +143,9 @@ const (
143
143
)
144
144
145
145
type raftScheduleState struct {
146
- flags raftScheduleFlags
146
+ flags raftScheduleFlags
147
+ // When this event was queued. This is set if and only if the item is present
148
+ // in the raft scheduler shard's queue.
147
149
queued crtime.Mono
148
150
149
151
// The number of ticks queued. Usually it's 0 or 1, but may go above if the
@@ -392,10 +394,11 @@ func (ss *raftSchedulerShard) worker(
392
394
ss .state [id ] = raftScheduleState {flags : stateQueued }
393
395
ss .Unlock ()
394
396
395
- // Record the scheduling latency for the range.
396
397
if buildutil .CrdbTestBuild && state .queued == 0 {
398
+ // See state.queued for the invariant being checked here.
397
399
log .Fatalf (ctx , "raftSchedulerShard.worker called with zero queued: %+v" , state )
398
400
}
401
+ // Record the scheduling latency for the range.
399
402
lat := state .queued .Elapsed ()
400
403
metrics .RaftSchedulerLatency .RecordValue (int64 (lat ))
401
404
@@ -504,6 +507,7 @@ func (ss *raftSchedulerShard) enqueue1Locked(
504
507
newState .flags |= stateQueued
505
508
queued ++
506
509
if buildutil .CrdbTestBuild && newState .queued != 0 {
510
+ // See newState.queued for the invariant being checked here.
507
511
log .Fatalf (context .Background (), "raftSchedulerShard.enqueue1Locked called with non-zero queued: %+v" , newState )
508
512
}
509
513
newState .queued = now
0 commit comments