diff --git a/src/cluster_slot_stats.c b/src/cluster_slot_stats.c index 515be588f..597cfa009 100644 --- a/src/cluster_slot_stats.c +++ b/src/cluster_slot_stats.c @@ -147,7 +147,7 @@ void clusterSlotStatsCommand(client *c) { } int i = 4; /* Next argument index, following ORDERBY */ int limit_counter = 0, asc_desc_counter = 0; - long limit; + long limit = CLUSTER_SLOTS; while (i < c->argc) { int moreargs = c->argc > i + 1; if (!strcasecmp(c->argv[i]->ptr, "limit") && moreargs) { diff --git a/tests/unit/cluster/slot-stats.tcl b/tests/unit/cluster/slot-stats.tcl index c2923dc8b..2ee950f7b 100644 --- a/tests/unit/cluster/slot-stats.tcl +++ b/tests/unit/cluster/slot-stats.tcl @@ -199,7 +199,7 @@ start_cluster 1 0 {tags {external:skip cluster}} { # ----------------------------------------------------------------------------- start_cluster 1 0 {tags {external:skip cluster}} { - + # SET keys for target hashslots, to encourage ordering. set hash_tags [list 0 1 2 3 4] set num_keys 1 @@ -220,6 +220,7 @@ start_cluster 1 0 {tags {external:skip cluster}} { test "CLUSTER SLOT-STATS ORDERBY DESC correct ordering" { set orderby "key-count" + assert_error "ERR*" {R 0 CLUSTER SLOT-STATS ORDERBY $orderby DESC LIMIT -1} set slot_stats [R 0 CLUSTER SLOT-STATS ORDERBY $orderby DESC] assert_slot_stats_monotonic_descent $slot_stats $orderby }