btlqql opened a new pull request, #7144:
URL: https://github.com/apache/rocketmq-dashboard/pull/7144

   ### Which Issue(s) This PR Fixes
   
   - Fixes #5974
   
   ## What is the purpose of the change
   
   `enrichLiveStats` starts every group from `GroupLiveSnapshot.empty()`, and 
when the 3 s batch deadline
   cancels a group's future before it runs, that untouched initial snapshot is 
the value applied to the
   returned `ConsumerGroupVO`. `empty()` hard-coded `onlineInstances = 0`, so a 
read that never happened
   reached the API as a measured "this group has no online clients": a green 0 
in the client column (where
   the sentinel renders as 不可用) and a critical "有堆积但无在线客户端" verdict for a group 
whose connection
   inventory was never read. The failure path in the same class already maps an 
unavailable lookup to `-1`,
   which is exactly what `ConsumerGroupVO.onlineInstances` documents ("-1 when 
connection inventory is
   unavailable"). This change makes the initial snapshot carry that sentinel 
too, so a cancelled enrichment
   is reported as unread rather than as a zero. Worker-written snapshots 
(available, unavailable and fully
   enriched) are untouched, and no other behaviour or API shape changes.
   
   ## Brief changelog
   
   - 
`server/src/main/java/org/apache/rocketmq/studio/provider/apache/RocketMQMetadataProvider.java`:
     `GroupLiveSnapshot.empty()` starts at the documented `-1` "inventory 
unavailable" sentinel instead of
     `0`, with a comment recording that the initial value is also the 
cancelled-deadline value.
   - 
`server/src/test/java/org/apache/rocketmq/studio/provider/apache/RocketMQMetadataProviderTest.java`:
     the existing `timedOutGroupEnrichmentMustNotMutateReturnedGroupTest` 
asserts `-1` both before and after
     the cancelled broker call completes, instead of pinning the fabricated `0`.
   
   ## Verifying this change
   
   ```
   red:   cd server && mvn -o -B -ntp test -Dtest='RocketMQMetadataProviderTest'
          [ERROR] 
RocketMQMetadataProviderTest.timedOutGroupEnrichmentMustNotMutateReturnedGroupTest:848
          expected: -1 / but was: 0
          [ERROR] Tests run: 54, Failures: 1, Errors: 0, Skipped: 0
          (log: group-enrich-cancel-red.log)
   
   green: cd server && mvn -o -B -ntp test -Dtest='RocketMQMetadataProviderTest'
          [INFO] Tests run: 54, Failures: 0, Errors: 0, Skipped: 0
          [INFO] BUILD SUCCESS
          (log: group-enrich-cancel-green.log)
   ```
   
   Regressions run: the whole `RocketMQMetadataProviderTest` class (54 tests), 
including
   `listConsumerGroupsShouldNotFetchLiveAdminInfoForEachGroup` (still expects 
`0` on the no-live-source
   path) and 
`listConsumerGroupsShouldMarkOnlineInstancesUnknownWhenConnectionLookupFailsTest`
 (the
   `-1` failure path) — `Tests run: 54, Failures: 0, Errors: 0`.
   
   Not run: the full server suite, the web suite, CI, and any live RocketMQ 
cluster. The change was
   verified through the provider's own unit tests only; I did not exercise the 
consumer page rendering of
   the sentinel end to end.
   
   ## Checklist
   
   - [x] One coherent change; unrelated modifications are not bundled in
   - [x] Commit subject follows Conventional Commits (`fix:`)
   - [x] Tests added or updated for non-trivial changes, test method named 
`...Test`
   - [ ] New UI text has both Chinese and English entries under `web/src/i18n/` 
— no UI text is added
   - [ ] Architecture constraints stay green (`mvn test` runs the ArchUnit 
checks) — checkstyle reported 0 violations in both runs, but the ArchUnit 
checks were not run (only the targeted test class was)
   - [ ] New source files carry the ASF license header — no new files
   - [ ] Documentation touched where behaviour changed — `ConsumerGroupVO` 
already documented the `-1` sentinel; this change makes the code match it
   - [x] one issue, one PR: Fixes #5974
   - [x] regression test added
   - [x] targeted suites re-run
   


-- 
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]

Reply via email to