Skip to content

[#2196] Improve queue consumer starvation under low configuration#2197

Open
mattrpav wants to merge 2 commits into
apache:mainfrom
mattrpav:amq-gh-2196-queue-consumer-starvation
Open

[#2196] Improve queue consumer starvation under low configuration#2197
mattrpav wants to merge 2 commits into
apache:mainfrom
mattrpav:amq-gh-2196-queue-consumer-starvation

Conversation

@mattrpav

@mattrpav mattrpav commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Run the test before the fix and observe:

2026-07-07 15:56:20,119 [me-limited test] - INFO  PriorityDispatchStarvationTest - Produced 200 messages (40 app, 160 other)
2026-07-07 15:56:30,154 [me-limited test] - INFO  PriorityDispatchStarvationTest - App consumer received 8 / 40 messages (drained=false)
2026-07-07 15:56:30,156 [me-limited test] - INFO  PriorityDispatchStarvationTest - Queue stats - queueSize: 192, enqueues: 200, dequeues: 8, inflight: 0, dispatched: 8

Test run after fix:

2026-07-07 15:59:33,076 [me-limited test] - INFO  PriorityDispatchStarvationTest - Produced 200 messages (40 app, 160 other)
2026-07-07 15:59:33,110 [ Session Task-1] - INFO  PriorityDispatchStarvationTest - App consumer received 10 / 40 messages
2026-07-07 15:59:33,115 [ Session Task-1] - INFO  PriorityDispatchStarvationTest - App consumer received 20 / 40 messages
2026-07-07 15:59:33,119 [ Session Task-1] - INFO  PriorityDispatchStarvationTest - App consumer received 30 / 40 messages
2026-07-07 15:59:33,123 [ Session Task-1] - INFO  PriorityDispatchStarvationTest - App consumer received 40 / 40 messages
2026-07-07 15:59:33,123 [me-limited test] - INFO  PriorityDispatchStarvationTest - App consumer received 40 / 40 messages (drained=true)
2026-07-07 15:59:33,124 [me-limited test] - INFO  PriorityDispatchStarvationTest - Queue stats - queueSize: 160, enqueues: 200, dequeues: 40, inflight: 0, dispatched: 40

edit: Tests passed, except for assembly on an address-in-use bind error. Re-running tests to get a green checkmark

@mattrpav mattrpav self-assigned this Jul 7, 2026
@mattrpav mattrpav changed the title [#2196] Queue consumer starvation under low configuration [#2196] Improve queue consumer starvation under low configuration Jul 7, 2026
@mattrpav mattrpav force-pushed the amq-gh-2196-queue-consumer-starvation branch from b733033 to 607f112 Compare July 7, 2026 21:03
@mattrpav mattrpav requested a review from cshannon July 7, 2026 21:03
mattrpav added 2 commits July 7, 2026 16:11
…figuration

Test demonstrates that stalled low-priority network consumers with saturated
prefetch throttle a normal-priority app consumer's throughput by 5-20x.
Root cause: Queue.doPageInForDispatch() uses dispatchPendingList.size()
against maxPageSize, so messages stuck behind full network consumers
block page-in for all consumers.

The test assertion (slowdownFactor <= 3.0) is expected to FAIL against
the current code, proving the bug exists. The subsequent fix commit
will make it pass.
…l prefetch

Queue.doPageInForDispatch() used pagedInPendingSize < maxPageSize as the
sole gate for paging in messages from the store. When low-priority network
consumers had saturated prefetch (not acking), their undispatched messages
accumulated in dispatchPendingList, counting against maxPageSize and
blocking page-in for all consumers — including higher-priority app
consumers with available prefetch capacity.

Two changes:
1. When pagedInPendingSize >= maxPageSize, cap toPageIn to what consumers
   can actually accept (getConsumerMessageCountBeforeFull)
2. Allow page-in when any consumer has available prefetch capacity, even
   if pagedInPendingSize >= maxPageSize
@mattrpav mattrpav force-pushed the amq-gh-2196-queue-consumer-starvation branch from 607f112 to a5b8ef9 Compare July 7, 2026 21:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Backlog

Development

Successfully merging this pull request may close these issues.

1 participant