Files
kumomta/docs
Wez Furlong cd6b01dfe9 throttle: fix edge case with 0ns throttle delay
The queue logic assumes that if we get Some(duration) back from a
throttle check that it must be a non-zero duration.

We found a configuration that used a custom lua delivery handler
together with a max_message_rate throttle. When running with local
(non-redis) throttles it is possible that the in-memory throttle
implementation can return a 0ns delay.

This results in the queue subsystem choosing to requeue the message
using the throttle duration as the delay, which results in the message
being due immediately, which causes recursion into the insert-ready
flow, which performs the same throttle check with the same 0ns result,
and repeat until a stack overflow occurs on the spool in thread.

The circumstances to trigger this are a bit niche and racy: if you turn
up debug logging you can perturb the timing so that the stack overflow
is not 100% repeatable. It is unlikely to cause a stack overflow on the
inbound processing side because the threads doing that processing are
multiplexing many other events that can also perturb the timing.

This commit addresses this edge case in a very simple way: if the
duration is 0, then we return `None` for the duration.  This is actually
how we handle this for one of the redis throttle implementations
already. This commit makes the other two cases consistent with that.
2025-02-26 08:43:05 -07:00
..
2023-10-18 16:18:56 -06:00
2025-02-13 14:42:16 -07:00
2025-02-20 16:00:16 -07:00
2025-02-20 13:04:57 +00:00
2025-02-20 16:00:16 -07:00