Skip to content

Commit

Permalink
Improve reliability of querybuf test (#639)
Browse files Browse the repository at this point in the history
We've been seeing some pretty consistent failures from
`test-valgrind-test` and `test-sanitizer-address` because of the
querybuf test periodically failing. I tracked it down to the test
periodically taking too long and the client cron getting triggered. A
simple solution is to just disable the cron during the key race
condition. I was able to run this locally for 100 iterations without
seeing a failure.

Example:
https://github.com/valkey-io/valkey/actions/runs/9474458354/job/26104103514
and
https://github.com/valkey-io/valkey/actions/runs/9474458354/job/26104106830.

Signed-off-by: Madelyn Olson <[email protected]>
  • Loading branch information
madolson authored Jun 12, 2024
1 parent 4bb7cc4 commit 627d387
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions tests/unit/querybuf.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ start_server {tags {"querybuf slow"}} {
# Make sure query buff has size of 0 bytes at start as the client uses the shared qb.
assert {[client_query_buffer test_client] == 0}

# Pause cron to prevent premature shrinking (timing issue).
r debug pause-cron 1

# Send partial command to client to make sure it doesn't use the shared qb.
$rd write "*3\r\n\$3\r\nset\r\n\$2\r\na"
$rd flush
Expand All @@ -48,6 +51,9 @@ start_server {tags {"querybuf slow"}} {
set MAX_QUERY_BUFFER_SIZE [expr 32768 + 2] ; # 32k + 2, allowing for potential greedy allocation of (16k + 1) * 2 bytes for the query buffer.
assert {$orig_test_client_qbuf >= 16384 && $orig_test_client_qbuf <= $MAX_QUERY_BUFFER_SIZE}

# Allow shrinking to occur
r debug pause-cron 0

# Check that the initial query buffer is resized after 2 sec
wait_for_condition 1000 10 {
[client_idle_sec test_client] >= 3 && [client_query_buffer test_client] < $orig_test_client_qbuf
Expand Down

0 comments on commit 627d387

Please sign in to comment.