Skip to content

Commit

Permalink
Minor revision.
Browse files Browse the repository at this point in the history
- Updated the reply schema to keep cpu-usec as optional.
- Updated integration test to assert against expected slots existence.
- Updated valkey.conf

Signed-off-by: Kyle Kim <[email protected]>
  • Loading branch information
kyle-yh-kim committed Jul 22, 2024
1 parent a28ee99 commit 1a1ce40
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/commands/cluster-slot-stats.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
"type": "object",
"description": "Map of slot usage statistics.",
"additionalProperties": false,
"required": [ "key-count" ],
"properties": {
"key-count": {
"type": "integer"
Expand Down
4 changes: 2 additions & 2 deletions src/server.c
Original file line number Diff line number Diff line change
Expand Up @@ -3546,8 +3546,8 @@ void call(client *c, int flags) {
* If the client is blocked we will handle slowlog when it is unblocked. */
if (!c->flag.blocked) freeClientOriginalArgv(c);

/* Populate the per-command and per-slot statistics that we show in INFO commandstats and CLUSTER SLOT-STATS, respectively.
* If the client is blocked we will handle latency stats and duration when it is unblocked. */
/* Populate the per-command and per-slot statistics that we show in INFO commandstats and CLUSTER SLOT-STATS,
* respectively. If the client is blocked we will handle latency stats and duration when it is unblocked. */
if (update_command_stats && !c->flag.blocked) {
real_cmd->calls++;
real_cmd->microseconds += c->duration;
Expand Down
3 changes: 3 additions & 0 deletions tests/unit/cluster/slot-stats.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ proc assert_empty_slot_stats {slot_stats metrics_to_assert} {

proc assert_empty_slot_stats_with_exception {slot_stats exception_slots metrics_to_assert} {
set slot_stats [convert_array_into_dict $slot_stats]
dict for {slot stats} $exception_slots {
assert {[dict exists $slot_stats $slot]} ;# slot_stats must contain the expected slots.
}
dict for {slot stats} $slot_stats {
if {[dict exists $exception_slots $slot]} {
foreach metric_name $metrics_to_assert {
Expand Down
4 changes: 4 additions & 0 deletions utils/generate-command-code.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,10 @@ def __init__(self, name, desc):
if isinstance(v, dict):
self.schema[k] = ReplySchema("%s_%s" % (self.name, k), v)
elif isinstance(v, list):
if k == "required":
# For now, we omit the handling of "required" field within the reply_schema.
# This should be revisited once reply_schema efforts are resumed.
continue
self.schema[k] = []
for i, subdesc in enumerate(v):
self.schema[k].append(ReplySchema("%s_%s_%i" % (self.name, k,i), subdesc))
Expand Down
2 changes: 1 addition & 1 deletion valkey.conf
Original file line number Diff line number Diff line change
Expand Up @@ -1789,7 +1789,7 @@ aof-timestamp-enabled no
# cluster-blacklist-ttl 60

# Clusters can be configured to track per-slot resource statistics,
# which are further accessible by the CLUSTER SLOT-STATS command.
# which are accessible by the CLUSTER SLOT-STATS command.
#
# By default, the 'cluster-slot-stats-enabled' is disabled, and only 'key-count' is captured.
# By enabling the 'cluster-slot-stats-enabled' config, the cluster will begin to capture advanced statistics.
Expand Down

0 comments on commit 1a1ce40

Please sign in to comment.