summaryrefslogtreecommitdiff
path: root/tests/integration
diff options
context:
space:
mode:
authorBinbin <binloveplay1314@qq.com>2022-11-28 19:03:55 +0800
committerGitHub <noreply@github.com>2022-11-28 13:03:55 +0200
commit06b577aad01d132b0792581a3f1235bc84a32026 (patch)
tree57ab2cb098e8d1792581341b2741e2ccd81f36b3 /tests/integration
parenteeca7f29117a5e376da3e6f1a419fdf5a6e78e8b (diff)
downloadredis-06b577aad01d132b0792581a3f1235bc84a32026.tar.gz
Fix replication on expired key test timing issue, give it more chances (#11548)
In replica, the key expired before master's `INCR` was arrived, so INCR creates a new key in the replica and the test failed. ``` *** [err]: Replication of an expired key does not delete the expired key in tests/integration/replication-4.tcl Expected '0' to be equal to '1' (context: type eval line 13 cmd {assert_equal 0 [$slave exists k]} proc ::test) ``` This test is very likely to do a false positive if the `wait_for_ofs_sync` takes longer than the expiration time, so give it a few more chances. The test was introduced in #9572.
Diffstat (limited to 'tests/integration')
-rw-r--r--tests/integration/replication-4.tcl24
1 files changed, 20 insertions, 4 deletions
diff --git a/tests/integration/replication-4.tcl b/tests/integration/replication-4.tcl
index 9f4281f7c..d7a8b92a6 100644
--- a/tests/integration/replication-4.tcl
+++ b/tests/integration/replication-4.tcl
@@ -122,19 +122,35 @@ start_server {tags {"repl external:skip"}} {
}
test {Replication of an expired key does not delete the expired key} {
+ # This test is very likely to do a false positive if the wait_for_ofs_sync
+ # takes longer than the expiration time, so give it a few more chances.
+ # Go with 5 retries of increasing timeout, i.e. start with 500ms, then go
+ # to 1000ms, 2000ms, 4000ms, 8000ms.
+ set px_ms 500
+ for {set i 0} {$i < 5} {incr i} {
+
+ wait_for_ofs_sync $master $slave
$master debug set-active-expire 0
- $master set k 1 ex 1
+ $master set k 1 px $px_ms
wait_for_ofs_sync $master $slave
exec kill -SIGSTOP [srv 0 pid]
$master incr k
- after 1001
+ after [expr $px_ms + 1]
# Stopping the replica for one second to makes sure the INCR arrives
# to the replica after the key is logically expired.
exec kill -SIGCONT [srv 0 pid]
wait_for_ofs_sync $master $slave
# Check that k is logically expired but is present in the replica.
- assert_equal 0 [$slave exists k]
- $slave debug object k ; # Raises exception if k is gone.
+ set res [$slave exists k]
+ set errcode [catch {$slave debug object k} err] ; # Raises exception if k is gone.
+ if {$res == 0 && $errcode == 0} { break }
+ set px_ms [expr $px_ms * 2]
+
+ } ;# for
+
+ if {$::verbose} { puts "Replication of an expired key does not delete the expired key test attempts: $i" }
+ assert_equal $res 0
+ assert_equal $errcode 0
}
}
}