zjncs opened a new pull request, #11113:
URL: https://github.com/apache/rocketmq/pull/11113
## Motivation
`RouteActivity.queryRoute` breaks out of the queueData loop as soon as one
queueData's brokerName has no matching entry in the broker map built from
`BrokerData`:
```java
Map<Long, Broker> brokerIdMap = brokerMap.get(brokerName);
if (brokerIdMap == null) {
break;
}
```
The namesrv assembles `TopicRouteData` from `queueTable` and
`brokerAddrTable` independently, so a route can carry a queueData whose broker
was just unregistered (e.g. broker shutdown between the two table reads, or a
stale queueData left behind during unregister races). With `break`, that single
orphan queueData makes `queryRoute` return **zero** message queues for the
topic even though every other broker in the route is healthy — clients then
fail all sends until the next route refresh. The sibling method
`queryAssignment` already handles the same condition by skipping only the
affected queueData, so `queryRoute` is inconsistent with it.
## Modification
In `RouteActivity.queryRoute`, change the `break` to `continue` so an orphan
queueData only drops its own queues and the remaining brokers' queues are still
served.
## Test Evidence
**Fail-before** (unpatched code, new test
`RouteActivityTest#testQueryRouteSkipsQueueDataOfUnregisteredBroker` with a
route whose first queueData references an unregistered broker):
```
docker exec rmq-build bash -c "export
JAVA_HOME=/usr/lib/jvm/java-17-openjdk-arm64; cd /repo && mvn -q -pl proxy test
-Dtest='RouteActivityTest#testQueryRouteSkipsQueueDataOfUnregisteredBroker'
-Dsurefire.failIfNoSpecifiedTests=true"
java.lang.AssertionError: expected:<4> but was:<0>
```
**Pass-after** (full class with the fix):
```
docker exec rmq-build bash -c "export
JAVA_HOME=/usr/lib/jvm/java-17-openjdk-arm64; cd /repo && mvn -q -pl proxy test
-Dtest='RouteActivityTest' -Dsurefire.failIfNoSpecifiedTests=true"
Tests run: 8, Failures: 0, Errors: 0, Skipped: 0
```
No associated issue (self-discovered during a proxy-module self-audit).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]