From 488aecb3abca3088735f1bffa60a74e22832d44b Mon Sep 17 00:00:00 2001 From: Binbin Date: Wed, 23 Feb 2022 14:47:16 +0800 Subject: [PATCH] Fix timing issue in EXEC fail on lazy expired WATCHed key test (#10332) The test will fail on slow machines (valgrind or FreeBsd). Because in #10256 when WATCH is called on a key that's already logically expired, we will add an `expired` flag, and we will skip it in `isWatchedKeyExpired` check. Apparently we need to increase the expiration time so that the key can not expire logically then the WATCH is called. Also added retries to make sure it doesn't fail. I suppose 100ms is enough in valgrind, tested locally, no need to retry. --- tests/unit/multi.tcl | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/tests/unit/multi.tcl b/tests/unit/multi.tcl index 70e33b74b..63d85d26b 100644 --- a/tests/unit/multi.tcl +++ b/tests/unit/multi.tcl @@ -132,20 +132,24 @@ start_server {tags {"multi"}} { } {} {cluster:skip} test {EXEC fail on lazy expired WATCHed key} { - r flushall + r del key r debug set-active-expire 0 - r del key - r set key 1 px 2 - r watch key + for {set j 0} {$j < 10} {incr j} { + r set key 1 px 100 + r watch key + after 101 + r multi + r incr key - after 100 + set res [r exec] + if {$res eq {}} break + } + if {$::verbose} { puts "EXEC fail on lazy expired WATCHed key attempts: $j" } - r multi - r incr key - assert_equal [r exec] {} r debug set-active-expire 1 - } {OK} {needs:debug} + set _ $res + } {} {needs:debug} test {WATCH stale keys should not fail EXEC} { r del x