[ISSUE #C2] Count down the queryMessage latch when the invocation fails - #11105
Open
zjncs wants to merge 1 commit into
Open
[ISSUE #C2] Count down the queryMessage latch when the invocation fails#11105zjncs wants to merge 1 commit into
zjncs wants to merge 1 commit into
Conversation
MQAdminImpl.queryMessage registers an InvokeCallback that releases the per-broker CountDownLatch, but when MQClientAPIImpl.queryMessage itself throws synchronously (e.g. RemotingConnectException for an unreachable broker) the callback never fires and the catch block only logs. The await(timeoutMillis * 4) below then blocks for the whole window — 24s with the default timeoutMillis of 6s — before reporting that no message was found. Release this broker's latch count in the catch block. Signed-off-by: zjncs <18910855655@163.com>
RockteMQ-AI
approved these changes
Sep 9, 2026
RockteMQ-AI
left a comment
Contributor
There was a problem hiding this comment.
Summary
Correct fix for a real stall — when MQClientAPIImpl.queryMessage throws synchronously (e.g. RemotingConnectException), the callback never fires and the latch is never decremented, causing the caller to block for the full timeoutMillis * 4 (24s default). Adding countDownLatch.countDown() in the catch block is the minimal correct fix. Test validates the timing improvement.
Automated review by github-manager
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
MQAdminImpl.queryMessagefans out one asynchronous query per broker and waits on aCountDownLatch(brokerAddrs.size()). The latch is released by theInvokeCallback(operationSucceed/operationFail), but ifMQClientAPIImpl.queryMessageitself throws synchronously — e.g.RemotingConnectException/RemotingTimeoutExceptionfor an unreachable broker — no callback is ever invoked, and the catch block only logs:The caller then blocks for the full
timeoutMillis * 4window — 24 seconds with the defaulttimeoutMillisof 6s — before getting the "no message" answer, even though the outcome was already known. Any tool/admin call that queries by key while one broker is down pays this stall.Modifications
countDownLatch.countDown();in the catch block, releasing this broker's count exactly as the callback would have.Verification
Fail-before (new test on unpatched code — the per-broker invoke is mocked to throw,
timeoutMillis=200):Pass-after — full
MQAdminImplTest(11 existing + 1 new); the same call now returns in single-digit milliseconds: