diff options
author | Binbin <binloveplay1314@qq.com> | 2022-11-28 19:03:55 +0800 |
---|---|---|
committer | Oran Agra <oran@redislabs.com> | 2022-12-12 17:36:34 +0200 |
commit | e2665c6fc0a3f6a24811721e63abcc8f237122a1 (patch) | |
tree | cf657490f1f909ed2df4ba492ec55f3af42da23d | |
parent | 3c525fab6ac61aaa3494cfa767f55d2967dc6004 (diff) | |
download | redis-e2665c6fc0a3f6a24811721e63abcc8f237122a1.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.
(cherry picked from commit 06b577aad01d132b0792581a3f1235bc84a32026)
-rw-r--r-- | tests/integration/replication-4.tcl | 24 |
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 } } } |