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.
This commit is contained in:
parent
857c09b04d
commit
e49c2a5292
@ -5,7 +5,7 @@ proc client_idle_sec {name} {
|
|||||||
return $idle
|
return $idle
|
||||||
}
|
}
|
||||||
|
|
||||||
# Calculate query buffer memory of slave
|
# Calculate query buffer memory of client
|
||||||
proc client_query_buffer {name} {
|
proc client_query_buffer {name} {
|
||||||
set clients [split [r client list] "\r\n"]
|
set clients [split [r client list] "\r\n"]
|
||||||
set c [lsearch -inline $clients *name=$name*]
|
set c [lsearch -inline $clients *name=$name*]
|
||||||
@ -20,6 +20,7 @@ proc client_query_buffer {name} {
|
|||||||
start_server {tags {"querybuf slow"}} {
|
start_server {tags {"querybuf slow"}} {
|
||||||
# increase the execution frequency of clientsCron
|
# increase the execution frequency of clientsCron
|
||||||
r config set hz 100
|
r config set hz 100
|
||||||
|
|
||||||
# The test will run at least 2s to check if client query
|
# The test will run at least 2s to check if client query
|
||||||
# buffer will be resized when client idle 2s.
|
# buffer will be resized when client idle 2s.
|
||||||
test "query buffer resized correctly" {
|
test "query buffer resized correctly" {
|
||||||
@ -40,6 +41,9 @@ start_server {tags {"querybuf slow"}} {
|
|||||||
}
|
}
|
||||||
|
|
||||||
test "query buffer resized correctly when not idle" {
|
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.
|
# Memory will increase by more than 32k due to client query buffer.
|
||||||
set rd [redis_client]
|
set rd [redis_client]
|
||||||
$rd client setname test_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]
|
set orig_test_client_qbuf [client_query_buffer test_client]
|
||||||
assert {$orig_test_client_qbuf > 32768}
|
assert {$orig_test_client_qbuf > 32768}
|
||||||
|
|
||||||
|
r debug pause-cron 0
|
||||||
|
|
||||||
# Wait for qbuf to shrink due to lower peak
|
# Wait for qbuf to shrink due to lower peak
|
||||||
set t [clock milliseconds]
|
set t [clock milliseconds]
|
||||||
while true {
|
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
|
# 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}
|
assert {[client_query_buffer test_client] > 0 && [client_query_buffer test_client] < $orig_test_client_qbuf}
|
||||||
$rd close
|
$rd close
|
||||||
}
|
} {0} {needs:debug}
|
||||||
|
|
||||||
test "query buffer resized correctly with fat argv" {
|
test "query buffer resized correctly with fat argv" {
|
||||||
set rd [redis_client]
|
set rd [redis_client]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user