Messages stuck indefinitely in a ready queue (never delivered, bounced, or expired) — max_age not enforced for ready-queue residents

I found a bug that results in stuck messages. I have a Github issue for it here: Messages stuck indefinitely in a ready queue (never delivered, bounced, or expired) — max_age not enforced for ready-queue residents · Issue #539 · KumoCorp/kumomta · GitHub

Summary
A message can remain in a ready queue indefinitely — never delivered, never bounced, and never expired — if that ready queue stops making delivery progress while still holding a backlog (e.g. a dispatcher/connection wedges without producing an error). max_age is only enforced on the scheduled-queue requeue path, so a message that is resident in a ready queue is never re-evaluated against max_age. The only mechanism that flushes a ready queue back to the scheduled queue (reaping) requires ready_count() == 0, which a wedged-with-backlog queue never reaches.

We hit this in production: ~11,140 messages across 14 nodes were stuck this way against ~8 different providers, some for 3+ days despite a 6h max_age. They showed up to customers as “accepted but no further events” (not delivered, not bounced, not expired).

Thank you for the report. Investigating