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

   ### Motivation
   
   `ApacheRocketMqBusinessMetricsCollector.queueLagSamples` clamps every 
`QueueProgressVO.diffTotal` with `Math.max(0, ...)`. But 
`RocketMQMetadataProvider.resolveDiff` deliberately passes the broker's `-1` 
unknown sentinel through into `diffTotal` (its javadoc: *"Resolves the lag for 
a single queue without clamping the broker's `-1` 'unknown' sentinel to zero… 
so the unknown state stays visible"* — typical for RocketMQ 5.0 gRPC 
consumers). The clamp therefore turns "lag unknown" into a fabricated 
**zero-lag AVAILABLE sample** for `consumer.lag.max_queue` and 
`topic.backlog.total`:
   
   - a "max queue lag > N" or "topic backlog > N" rule never fires while the 
state is unknown;
   - an already-FIRING alert receives healthy `0`s and falsely resolves;
   - window aggregations (AVG/MAX) are diluted with fake `0`s;
   - and because a sample *is* emitted, `reconcileMissingActiveStates` never 
sees a gap to reconcile — the unknown state is fully masked.
   
   This is the same defect #3988 fixed for `consumer.lag.total` (its comment: 
*"do not clamp it into a fabricated zero-lag AVAILABLE sample that would feed 
consumer.lag.total alerts a fake 0"*). The sibling `queueLagSamples` path was 
not covered by that fix.
   
   ### Modifications
   
   `queueLagSamples` first checks whether any progress row carries 
`ConsumerLagResolver.UNKNOWN`; if so it returns UNAVAILABLE samples with reason 
`CONSUMER_LAG_UNKNOWN` for both affected metrics (mirroring the fixed 
`totalLag` path). The `Math.max(0, ...)` clamp is kept for the normal path, 
guarding only genuinely impossible negatives.
   
   ### Verification
   
   New test `reportsUnavailableQueueLagWhenProgressCarriesSentinelTest` 
(modeled on `reportsUnavailableTotalLagWhenSentinelUnknownTest`) stubs 
`getGroupProgress` with `diffTotal = ConsumerLagResolver.UNKNOWN`:
   - Before the fix: fails — samples come back `AVAILABLE` with a fabricated 
`0`.
   - After the fix: passes — both metrics are `UNAVAILABLE`, value `null`, 
reason `CONSUMER_LAG_UNKNOWN`.
   - Full metrics module regression: `mvn -f server/pom.xml test 
-Dtest='org.apache.rocketmq.studio.cluster.metrics.**'` → **Tests run: 142, 
Failures: 0, Errors: 0**.
   


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