Skip to content

ARTEMIS-6390 Request credits on acquire race - #6957

Open
amterp wants to merge 1 commit into
apache:mainfrom
amterp:ARTEMIS-6390-bridge-credit-race
Open

amterp wants to merge 1 commit into
apache:mainfrom
amterp:ARTEMIS-6390-bridge-credit-race

Conversation

@amterp

@amterp amterp commented Nov 27, 2026

Copy link
Copy Markdown

Full context on https://issues.apache.org/jira/browse/ARTEMIS-6390

I've trialed this in our setup for a few weeks and it seems to have eliminated all the stalls we were previously regularly hitting.

Let me know if you have any thoughts on alternative approaches, or feedback on any part of the PR. I'm hoping to contribute some additional things I've found while working with Artemis, so I'm keen to learn the ropes around here properly :)

AbstractProducerCreditsImpl.acquireCredits runs checkCredits and
actualAcquire under separate synchronized blocks. On a large message,
a credit grant can land in that gap and leave balance positive (so
receiveCredits skips its starve rescue) and arriving == 0, yet below
the chunk size. actualAcquire then subtracts the chunk, blocks the
bridge with balance <= 0 and arriving == 0, and requests no credits.
On the final chunk, nothing calls checkCredits again and the bridge
stalls permanently.

In AsynchronousProducerCreditsImpl.actualAcquire, request the same
starve counterbalance (-balance + windowSize * 2) when balance <= 0
and arriving == 0, calling requestCredits outside synchronized (this)
to avoid blocking failover reset().

Assisted-by: Claude Code
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant