summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorantirez <antirez@gmail.com>2018-07-20 09:36:44 +0200
committerantirez <antirez@gmail.com>2018-07-20 09:36:48 +0200
commitaba6855282759feed747fb80cd947f86d5039335 (patch)
tree3c6d3c6d19f7bb97112b2e2758ae844a5e30a52e
parentbe88c0b16a53f5763d8fc1ae683f99ee39b0d68e (diff)
downloadredis-aba6855282759feed747fb80cd947f86d5039335.tar.gz
Clarify that clientsCronTrackExpansiveClients() indexes may jump ahead.
-rw-r--r--src/server.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/server.c b/src/server.c
index 8d49b5bf0..1cb7a9e8e 100644
--- a/src/server.c
+++ b/src/server.c
@@ -909,7 +909,15 @@ int clientsCronTrackExpansiveClients(client *c) {
/* Always zero the next sample, so that when we switch to that second, we'll
* only register samples that are greater in that second without considering
- * the history of such slot. */
+ * the history of such slot.
+ *
+ * Note: our index may jump to any random position if serverCron() is not
+ * called for some reason with the normal frequency, for instance because
+ * some slow command is called taking multiple seconds to execute. In that
+ * case our array may end containing data which is potentially older
+ * than CLIENTS_PEAK_MEM_USAGE_SLOTS seconds: however this is not a problem
+ * since here we want just to track if "recently" there were very expansive
+ * clients from the POV of memory usage. */
ClientsPeakMemInput[zeroidx] = 0;
ClientsPeakMemOutput[zeroidx] = 0;