Unverified Commit 03347d04 authored by Binbin's avatar Binbin Committed by GitHub
Browse files

Fix unstable test: replication with parallel clients writing in different DBs (#11782)

Failure happens in FreeBSD daily:
```
*** [err]: Test replication with parallel clients writing in different DBs in tests/integration/replication-4.tcl
Expected [::redis::redisHandle2 dbsize] > 0 (context: type eval line 19 cmd {assert {[$master dbsize] > 0}} proc ::test)
```

The test is failing because db 9 has no data (default db), and
according to the log, we can see that db 9 does not have a key:
```
 ### Starting test Test replication with parallel clients writing in different DBs in tests/integration/replication-4.tcl
3338:S 03 Feb 2023 00:15:18.723 - DB 11: 1 keys (0 volatile) in 4 slots HT.
3338:S 03 Feb 2023 00:15:18.723 - DB 12: 141 keys (0 volatile) in 256 slots HT.
```

We use `wait_for_condition` to ensure that parallel clients have
written data before calling stop_bg_complex_data. At the same time,
`wait_for_condition` is also used to remove the above `after 1000`,
which can save time in most cases.
parent 5a3cdddd
start_server {tags {"repl network external:skip"}} { start_server {tags {"repl network external:skip singledb:skip"}} {
start_server {} { start_server {} {
set master [srv -1 client] set master [srv -1 client]
...@@ -12,12 +12,26 @@ start_server {tags {"repl network external:skip"}} { ...@@ -12,12 +12,26 @@ start_server {tags {"repl network external:skip"}} {
test {First server should have role slave after SLAVEOF} { test {First server should have role slave after SLAVEOF} {
$slave slaveof $master_host $master_port $slave slaveof $master_host $master_port
after 1000 wait_for_condition 50 100 {
s 0 role [s 0 role] eq {slave}
} {slave} } else {
fail "Replication not started."
}
}
test {Test replication with parallel clients writing in different DBs} { test {Test replication with parallel clients writing in different DBs} {
# Gives the random workloads a chance to add some complex commands.
after 5000 after 5000
# Make sure all parallel clients have written data.
wait_for_condition 1000 50 {
[$master select 9] == {OK} && [$master dbsize] > 0 &&
[$master select 11] == {OK} && [$master dbsize] > 0 &&
[$master select 12] == {OK} && [$master dbsize] > 0
} else {
fail "Parallel clients are not writing in different DBs."
}
stop_bg_complex_data $load_handle0 stop_bg_complex_data $load_handle0
stop_bg_complex_data $load_handle1 stop_bg_complex_data $load_handle1
stop_bg_complex_data $load_handle2 stop_bg_complex_data $load_handle2
...@@ -34,7 +48,6 @@ start_server {tags {"repl network external:skip"}} { ...@@ -34,7 +48,6 @@ start_server {tags {"repl network external:skip"}} {
close $fd close $fd
fail "Master - Replica inconsistency, Run diff -u against /tmp/repldump*.txt for more info" fail "Master - Replica inconsistency, Run diff -u against /tmp/repldump*.txt for more info"
} }
assert {[$master dbsize] > 0}
} }
} }
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment