summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBinbin <binloveplay1314@qq.com>2023-05-04 18:02:08 +0800
committerGitHub <noreply@github.com>2023-05-04 13:02:08 +0300
commite49c2a52922f1c86eb94b42206cb9d50e1aeb431 (patch)
tree41c83e68fc7277eff1281aa0a0f0dc714e112c78
parent857c09b04d7be1b016956e55a9f7b8118585c59b (diff)
downloadredis-e49c2a52922f1c86eb94b42206cb9d50e1aeb431.tar.gz
Pause cron to prevent premature shrinking in querybuf test (#12126)
Tests occasionally fail since #12000: ``` *** [err]: query buffer resized correctly when not idle in tests/unit/querybuf.tcl Expected 0 > 32768 (context: type eval line 11 cmd {assert {$orig_test_client_qbuf > 32768}} proc ::test) *** [err]: query buffer resized correctly with fat argv in tests/unit/querybuf.tcl query buffer should not be resized when client idle time smaller than 2s ``` The reason may be because we set hz to 100, querybuf shrinks before we count client_query_buffer. We avoid this problem by setting pause-cron to 1.
-rw-r--r--tests/unit/querybuf.tcl10
1 files changed, 8 insertions, 2 deletions
diff --git a/tests/unit/querybuf.tcl b/tests/unit/querybuf.tcl
index c66f5c250..f4859dd27 100644
--- a/tests/unit/querybuf.tcl
+++ b/tests/unit/querybuf.tcl
@@ -5,7 +5,7 @@ proc client_idle_sec {name} {
return $idle
}
-# Calculate query buffer memory of slave
+# Calculate query buffer memory of client
proc client_query_buffer {name} {
set clients [split [r client list] "\r\n"]
set c [lsearch -inline $clients *name=$name*]
@@ -20,6 +20,7 @@ proc client_query_buffer {name} {
start_server {tags {"querybuf slow"}} {
# increase the execution frequency of clientsCron
r config set hz 100
+
# The test will run at least 2s to check if client query
# buffer will be resized when client idle 2s.
test "query buffer resized correctly" {
@@ -40,6 +41,9 @@ start_server {tags {"querybuf slow"}} {
}
test "query buffer resized correctly when not idle" {
+ # Pause cron to prevent premature shrinking (timing issue).
+ r debug pause-cron 1
+
# Memory will increase by more than 32k due to client query buffer.
set rd [redis_client]
$rd client setname test_client
@@ -51,6 +55,8 @@ start_server {tags {"querybuf slow"}} {
set orig_test_client_qbuf [client_query_buffer test_client]
assert {$orig_test_client_qbuf > 32768}
+ r debug pause-cron 0
+
# Wait for qbuf to shrink due to lower peak
set t [clock milliseconds]
while true {
@@ -64,7 +70,7 @@ start_server {tags {"querybuf slow"}} {
# Validate qbuf shrunk but isn't 0 since we maintain room based on latest peak
assert {[client_query_buffer test_client] > 0 && [client_query_buffer test_client] < $orig_test_client_qbuf}
$rd close
- }
+ } {0} {needs:debug}
test "query buffer resized correctly with fat argv" {
set rd [redis_client]