diff options
author | Madelyn Olson <34459052+madolson@users.noreply.github.com> | 2023-03-29 19:58:51 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-03-29 19:58:51 -0700 |
commit | 971b177fa338fe06cb67a930c6e54467d29ec44f (patch) | |
tree | 441962ff76914ce9ea2ff97b2ab763568c8d62ab /src/server.c | |
parent | 0c3b8b7e90ea242640a417abb5c40f30dfc3e036 (diff) | |
download | redis-971b177fa338fe06cb67a930c6e54467d29ec44f.tar.gz |
Fixed tracking of command duration for multi/eval/module/wait (#11970)
In #11012, we changed the way command durations were computed to handle the same command being executed multiple times. This commit fixes some misses from that commit.
* Wait commands were not correctly reporting their duration if the timeout was reached.
* Multi/scripts/and modules with RM_Call were not properly resetting the duration between inner calls, leading to them reporting cumulative duration.
* When a blocked client is freed, the call and duration are always discarded.
This commit also adds an assert if the duration is not properly reset, potentially indicating that a report to call statistics was missed. The assert potentially be removed in the future, as it's mainly intended to detect misses in tests.
Diffstat (limited to 'src/server.c')
-rw-r--r-- | src/server.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/server.c b/src/server.c index 4855ee1a8..00dfcb776 100644 --- a/src/server.c +++ b/src/server.c @@ -3596,6 +3596,12 @@ void call(client *c, int flags) { updateCommandLatencyHistogram(&(real_cmd->latency_histogram), c->duration*1000); } + /* The duration needs to be reset after each call except for a blocked command, + * which is expected to record and reset the duration after unblocking. */ + if (!(c->flags & CLIENT_BLOCKED)) { + c->duration = 0; + } + /* Propagate the command into the AOF and replication link. * We never propagate EXEC explicitly, it will be implicitly * propagated if needed (see propagatePendingCommands). |