From bc2757df12d5797a29144483b7c9bca0d9ead1ca Mon Sep 17 00:00:00 2001 From: "zhaozhao.zz" Date: Tue, 7 Jan 2025 18:58:33 +0800 Subject: [PATCH] add paused_actions for INFO stats Signed-off-by: zhaozhao.zz --- src/server.c | 4 +++- tests/unit/pause.tcl | 15 +++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/server.c b/src/server.c index 54b92c1f6a..85a06c7b17 100644 --- a/src/server.c +++ b/src/server.c @@ -5863,6 +5863,7 @@ sds genValkeyInfoString(dict *section_dict, int all_sections, int everything) { server.stat_last_eviction_exceeded_time ? (long long)elapsedUs(server.stat_last_eviction_exceeded_time) : 0; long long current_active_defrag_time = server.stat_last_active_defrag_time ? (long long)elapsedUs(server.stat_last_active_defrag_time) : 0; + char *paused_actions = server.paused_actions & PAUSE_ACTION_CLIENT_ALL ? "all" : server.paused_actions & PAUSE_ACTION_CLIENT_WRITE ? "write" : "none"; if (sections++) info = sdscat(info, "\r\n"); info = sdscatprintf( @@ -5930,7 +5931,8 @@ sds genValkeyInfoString(dict *section_dict, int all_sections, int everything) { "eventloop_duration_sum:%llu\r\n", server.duration_stats[EL_DURATION_TYPE_EL].sum, "eventloop_duration_cmd_sum:%llu\r\n", server.duration_stats[EL_DURATION_TYPE_CMD].sum, "instantaneous_eventloop_cycles_per_sec:%llu\r\n", getInstantaneousMetric(STATS_METRIC_EL_CYCLE), - "instantaneous_eventloop_duration_usec:%llu\r\n", getInstantaneousMetric(STATS_METRIC_EL_DURATION))); + "instantaneous_eventloop_duration_usec:%llu\r\n", getInstantaneousMetric(STATS_METRIC_EL_DURATION), + "paused_actions:%s\r\n", paused_actions)); info = genValkeyInfoStringACLStats(info); } diff --git a/tests/unit/pause.tcl b/tests/unit/pause.tcl index b18a32d48f..704e22df7c 100644 --- a/tests/unit/pause.tcl +++ b/tests/unit/pause.tcl @@ -1,4 +1,19 @@ start_server {tags {"pause network"}} { + test "Test check paused_actions in info stats" { + assert_equal [s paused_actions] "none" + + r client PAUSE 10000 WRITE + assert_equal [s paused_actions] "write" + r client unpause + + r multi + r client PAUSE 1000 All + r info stats + assert_match "*paused_actions:all*" [r exec] + + r client unpause + } + test "Test read commands are not blocked by client pause" { r client PAUSE 100000 WRITE set rd [valkey_deferring_client]