Repository: valkey-io/valkey (2025-08-08T10:52:32Z)

Issue:
Make CONFIG RESETSTATS reset all cluster stats.
Currently CONFIG RESET STATS only resets the slot statistics.
I think we should also include:

stats_bus_messages_sent
stats_bus_messages_received




Discussion:
why we need to reset stats_pfail_nodes, we will reset it in clusterCron and re-calc it anyway
I assigned it to myself for now since someone from my team want to make some contributions
> we need to reset stats_pfail_nodes, we will reset it in clusterCron and re-calc it anyway

I agree. I added it without lots of thoughts...



Patch:
diff --git a/src/cluster.c b/src/cluster.c
index dd83a33244..33882b0b0a 100644
--- a/src/cluster.c
+++ b/src/cluster.c
@@ -1594,6 +1594,10 @@ void resetClusterStats(void) {
     if (!server.cluster_enabled) return;
 
     clusterSlotStatResetAll();
+
+    memset(server.cluster->stats_bus_messages_sent, 0, sizeof(server.cluster->stats_bus_messages_sent));
+    memset(server.cluster->stats_bus_messages_received, 0, sizeof(server.cluster->stats_bus_messages_received));
+    server.cluster->stat_cluster_links_buffer_limit_exceeded = 0;
 }
 
 


Test patch:
diff --git a/tests/unit/cluster/info.tcl b/tests/unit/cluster/info.tcl
index 6c8f77b25b..43a2b7498e 100644
--- a/tests/unit/cluster/info.tcl
+++ b/tests/unit/cluster/info.tcl
@@ -63,6 +63,28 @@ start_cluster 3 0 {tags {external:skip cluster} overrides {cluster-node-timeout
         resume_process [srv -1 pid]
         wait_for_cluster_state ok
     }
+
+    test "CONFIG RESETSTAT resets cluster related stats" {
+        R 0 config set cluster-link-sendbuf-limit 1
+        wait_for_condition 1000 10 {
+            [CI 0 cluster_stats_messages_sent] >= 1 &&
+            [CI 0 cluster_stats_messages_received] >= 1 &&
+            [CI 0 total_cluster_links_buffer_limit_exceeded] >= 1
+        } else {
+            fail "R 0 related info fields are not as expected"
+        }
+
+        R 0 multi
+        R 0 config resetstat
+        R 0 cluster info
+        set info [lindex [R 0 exec] 1]
+        
+        assert_equal [getInfoProperty $info cluster_stats_messages_sent] 0
+        assert_equal [getInfoProperty $info cluster_stats_messages_received] 0
+        assert_equal [getInfoProperty $info total_cluster_links_buffer_limit_exceeded] 0
+
+        R 0 config set cluster-link-sendbuf-limit 0
+    }    
 }
 
 start_cluster 3 0 {tags {external:skip cluster} overrides {cluster-node-timeout 1000}} {