473
defer tr.lock.Unlock()
474
if tr.ackLevel == tr.readLevel {
475
>
// This is called after we read a range and find no tasks. The range we read was tr.readLevel to newReadLevel.
pri_task_reader.go
476
>
// (We know this because nothing should change tr.readLevel except the getTasksPump loop itself, after initialization.
477
>
// And getTasksPump doesn't start until it gets a signal from taskWriter that it's initialized the levels.)
478
>
// If we've acked all tasks up to tr.readLevel, and there are no tasks between that and newReadLevel, then we've
479
>
// acked all tasks up to newReadLevel too. This lets us advance the ack level on a task queue with no activity
480
>
// but where the rangeid has moved higher, to prevent excessive reads on the next load.
481
>
tr.ackLevel = newReadLevel
482
>
// Push the updated ack level to the db. If we didn't do this here, the updated ack level
483
>
// wouldn't reach the db until another task is written and acked, which could be far in the
484
>
// future. This also lets the approximate backlog count reset if we've reached max read level.
485
>
tr.backlogMgr.db.updateAckLevelAndBacklogStats(tr.subqueue, tr.ackLevel, 0, tr.backlogAge.oldestTime())
486
>
}
487
tr.readLevel = newReadLevel
488
}