zjncs opened a new pull request, #5518:
URL: https://github.com/apache/rocketmq-dashboard/pull/5518
## Problem
`discoverParentTopics` already unions consumer groups across masters because
— per its own comment — *"a parent topic can be sharded across brokers; the
group binding is reported by whichever broker owns the lite topic"*. But
`buildSummary` then read the parent's **lite topic count** and each group's
**lag** from a single address:
```java
private void merge(String brokerAddr, Integer ttlMinutes) {
this.brokerAddr = brokerAddr; // last master wins
...
}
...
GetParentTopicInfoResponseBody parentInfo =
admin.getParentTopicInfo(parent.brokerAddr, parent.parentTopic);
topicCount = Math.max(parentInfo.getLiteTopicCount(), 0); // one
master only
...
totalBacklog += groupLag(admin, parent.brokerAddr, group); // one
master only
```
On a parent sharded across brokers, each master only counts **its own** lite
topics and holds **its own** share of the group's lag — every other master's
numbers were silently dropped:
- parent split across two brokers with 2 + 3 lite topics displayed **3**
(whichever master iterated last), not 5;
- a group holding lag 7 + 5 across the two brokers displayed **5**, not 12.
The single-broker read also depended on the master iteration order through
`merge()`'s overwrite, so the displayed numbers could even change between
queries.
## Fix
`ParentTopicAccumulator` now records **every master that reported the
parent** and, **per group, the masters that reported the group**:
- `topicCount` sums `getParentTopicInfo(master, parent).getLiteTopicCount()`
over all reporting masters (each read keeps the existing per-call try/catch
degradation);
- group lag sums `groupLag(master, group)` over exactly the masters that
reported that group, so an unsharded group is never double-counted and a group
spanning brokers is fully counted.
A parent reported by a single master (the unsharded case) still reads from
that master alone — the existing single-master test passes unchanged.
## Verification
New test `listLiteTopicsSumsCountAndBacklogAcrossMasters`: two masters both
report the parent and the group with disjoint counts (2+3 lite topics, lag 7+5).
- before the fix: **fails** — `topicCount` was 3 (single master,
last-writer) instead of 5;
- after: **23/23** in `RocketMQLiteTopicProviderTest`;
- mutation (revert the provider, keep the test): back to 1 failed; restore:
23/23;
- regression: `LiteTopicServiceTest` + `LiteTopicControllerTest` — 43/43
across the three classes, including the pre-existing single-master aggregation
test.
--
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]