mirror of
https://github.com/mailscope/kumomta.git
synced 2026-10-29 17:46:53 +00:00
The timerwheel achieves its cheap insertion and removal by bucketing events with a slight loss in precision. It is possible for messages to be popped because they are due "now", but the precise now value for any given message might still be a small number (tens) of milliseconds in the future. Separately from this, there is logic that checks to see if the various throttling related events have delayed any messages and will reinsert those messages into the scheduled queue. That logic can be falsely triggered by the slight imprecision and cause a message to miss its true scheduling window. I've observed this case manifest in the retry_schedule test case. This commit deals with this case by ensuring that we wait until all of the due messages are really due; in practice this is either 0ns or ~20ms.