Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve consumer pending count tracking during stream contention (#6297)
The drifting tests would occasionally fail due to the consumer pending count drifting. This was due to a race condition described on `checkNumPending`: ``` // Does some sanity checks to see if we should re-calculate. // Since there is a race when decrementing when there is contention at the beginning of the stream. // The race is a getNextMsg skips a deleted msg, and then the decStreamPending call fires. // This does some quick sanity checks to see if we should re-calculate num pending. // Lock should be held. func (o *consumer) checkNumPending() uint64 { ``` This PR doesn't fix this race condition, but improves the tracking which improves test reliability. If the race condition happens we can still check if the deleted message is between `o.asflr` and the `o.sseq` that's skipped ahead. In which case we can still decrement the pending count (`o.npc`) if the message is not pending/delivered. This improves the reliability of the pending count tracking as long as the ack floor hasn't moved up yet. Signed-off-by: Maurice van Veen <github@mauricevanveen.com>
- Loading branch information