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

   ## Motivation
   
   `RocketMQMetadataProvider.enrichGroupLiveStats` (consumer group list 
enrichment) and `RocketMQAdminClientImpl.fillConsumeStats` (group detail) 
accumulate per-queue lag with a legacy clamp:
   
   ```java
   long diff = wrapper.getBrokerOffset() - wrapper.getConsumerOffset();
   if (diff > 0) {
       totalLag += diff;
   }
   ```
   
   A queue whose raw diff is negative — the `-1` unknown sentinel RocketMQ 5.0 
gRPC consumers report — therefore **silently contributes zero** to `totalLag`:
   
   - a group that also has healthy queues shows a **partial sum presented as 
the total**;
   - a group whose queues are all unknown shows a **fabricated zero lag** with 
`consumeStatsAvailable=true`.
   
   `ConsumerLagResolver` was introduced in this codebase exactly to keep that 
state visible — `getTopicConsumersPage` and `getGroupProgress` already resolve 
every diff through it and propagate `UNKNOWN` when any queue is unknown. The 
web UI also already handles the sentinel (`web/src/utils/consumerLag.ts`: 
`isLagAvailable`/`formatLag` render `-1` as an explicit gray "unavailable" 
state in the group list and detail). These two aggregation sites were simply 
left on the pre-resolver clamping behavior, so the UI's unknown-lag rendering 
never gets a chance to trigger for them.
   
   ## Modification
   
   Route both loops through `ConsumerLagResolver`:
   
   - `enrichGroupLiveStats` uses the existing `resolveDiff` helper (via the 
class's `proxyStatsProvider`);
   - `fillConsumeStats` resolves with no proxy (matching 
`ConsumerLagResolver`'s documented no-proxy behavior);
   - any queue resolving to `UNKNOWN` marks the whole `totalLag` unknown — the 
same semantics `getTopicConsumersPage` already applies to `diffTotal` — while 
the delay-seconds timestamp scan still covers every queue.
   
   ## Verification
   
   Added one regression test per site (`offset(100, 60)` healthy queue + 
`offset(0, 1)` sentinel queue — the same stub shape the existing 
`getTopicConsumersKeepsUnknownWhenAnyQueueLagIsUnknown` test uses):
   
   - 
`RocketMQAdminClientImplTest.getConsumerGroupReportsUnknownTotalLagWhenAnyQueueOffsetIsUnknownTest`
   - 
`RocketMQMetadataProviderTest.listConsumerGroupsShouldReportUnknownTotalLagWhenAnyQueueOffsetIsUnknownTest`
   
   Both **fail on the base branch** with `expected: -1L but was: 40L` (the 
sentinel queue is summed away and the partial 40 is reported as the total) and 
pass with this change.
   
   `mvn -pl server test 
-Dtest='org.apache.rocketmq.studio.provider.apache.*Test'` → full provider 
package green (RocketMQAdminClientImplTest 42/42, RocketMQMetadataProviderTest 
36/36, ConsumerLagResolverTest 5/5, …).


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