This is an automated email from the ASF dual-hosted git repository.

lizhimins pushed a commit to branch rocketmq-studio
in repository https://gitbox.apache.org/repos/asf/rocketmq-dashboard.git


The following commit(s) were added to refs/heads/rocketmq-studio by this push:
     new e5def86d7 fix(consumer): report the -1 sentinel when a group 
enrichment is cancelled by the batch deadline (#7144)
e5def86d7 is described below

commit e5def86d7a9d5fe5c17522f5e2bbbd375d12ccde
Author: btlqql <[email protected]>
AuthorDate: Mon Oct 26 20:35:45 2026 +0800

    fix(consumer): report the -1 sentinel when a group enrichment is cancelled 
by the batch deadline (#7144)
    
    * fix(consumer): report the -1 sentinel when a group enrichment is 
cancelled by the batch deadline
    The 3 s batch deadline cancels a group future before it runs, and the 
untouched initial
    GroupLiveSnapshot.empty() is then applied to the returned ConsumerGroupVO. 
empty() hard-coded
    onlineInstances 0, so an inventory that was never read reached the API as a 
measured "no clients
    online" (green 0 instead of 不可用) and could raise a critical "有堆积但无在线客户端" 
alert from no data.
    Start the initial snapshot at the -1 "inventory unavailable" sentinel that 
ConsumerGroupVO
    documents and that the failure path already uses, and pin it by extending 
the existing
    timedOutGroupEnrichmentMustNotMutateReturnedGroupTest to assert -1. 
Worker-written snapshots are
    untouched.
---
 .../rocketmq/studio/provider/apache/RocketMQMetadataProvider.java   | 6 +++++-
 .../studio/provider/apache/RocketMQMetadataProviderTest.java        | 6 ++++--
 2 files changed, 9 insertions(+), 3 deletions(-)

diff --git 
a/server/src/main/java/org/apache/rocketmq/studio/provider/apache/RocketMQMetadataProvider.java
 
b/server/src/main/java/org/apache/rocketmq/studio/provider/apache/RocketMQMetadataProvider.java
index acab23c8e..456643478 100644
--- 
a/server/src/main/java/org/apache/rocketmq/studio/provider/apache/RocketMQMetadataProvider.java
+++ 
b/server/src/main/java/org/apache/rocketmq/studio/provider/apache/RocketMQMetadataProvider.java
@@ -319,7 +319,11 @@ public class RocketMQMetadataProvider implements 
MetadataProvider {
             boolean consumeStatsAvailable, long totalLag, int delaySeconds,
             boolean consumptionTimestampAvailable) {
         private static GroupLiveSnapshot empty() {
-            return new GroupLiveSnapshot(List.of(), 0, false, 0L, 0, false);
+            // The snapshot every group starts from. It is also what is 
applied when the batch
+            // deadline cancels the future before it runs, so the online count 
must stay the
+            // documented -1 "inventory unavailable" sentinel (see 
ConsumerGroupVO) instead of a
+            // fabricated 0 that reads as "no clients online". Workers 
overwrite it with real data.
+            return new GroupLiveSnapshot(List.of(), -1, false, 0L, 0, false);
         }
     }
 
diff --git 
a/server/src/test/java/org/apache/rocketmq/studio/provider/apache/RocketMQMetadataProviderTest.java
 
b/server/src/test/java/org/apache/rocketmq/studio/provider/apache/RocketMQMetadataProviderTest.java
index 4ce06642d..03de6cfa7 100644
--- 
a/server/src/test/java/org/apache/rocketmq/studio/provider/apache/RocketMQMetadataProviderTest.java
+++ 
b/server/src/test/java/org/apache/rocketmq/studio/provider/apache/RocketMQMetadataProviderTest.java
@@ -865,11 +865,13 @@ class RocketMQMetadataProviderTest {
         try {
             ConsumerGroupVO returned = 
provider.listConsumerGroups("instance-a", null, null).get(0);
             assertThat(connectionStarted.getCount()).isZero();
-            assertThat(returned.getOnlineInstances()).isZero();
+            // A cancelled enrichment is an unread inventory, not a measured 
zero: the group must
+            // carry the documented -1 sentinel instead of claiming no clients 
are online.
+            assertThat(returned.getOnlineInstances()).isEqualTo(-1);
 
             releaseConnection.countDown();
             assertThat(statsRead.await(5, TimeUnit.SECONDS)).isTrue();
-            assertThat(returned.getOnlineInstances()).isZero();
+            assertThat(returned.getOnlineInstances()).isEqualTo(-1);
             assertThat(returned.getInstances()).isEmpty();
         } finally {
             releaseConnection.countDown();

Reply via email to