Skip to content

Commit

Permalink
Fix replication on expired key test timing issue, give it more chances (
Browse files Browse the repository at this point in the history
#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.
  • Loading branch information
enjoy-binbin committed Nov 28, 2022
1 parent eeca7f2 commit 06b577a
Showing 1 changed file with 20 additions and 4 deletions.
24 changes: 20 additions & 4 deletions tests/integration/replication-4.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
}
Expand Down

0 comments on commit 06b577a

Please sign in to comment.