Skip to content

Commit 95849c9

Browse files
committed
Deflake diskless timeout rdb pipe test by tolerating either timeout-disconnect branch
The "diskless timeout replicas drop during rdb pipe" subcase in tests/integration/replication.tcl waits for a "(full sync)" timeout disconnect log. On test-macos-latest the disconnect can surface on the "(streaming sync)" branch instead, because the RDB child exits and clears server.rdb_child_type (src/rdb.c:3698) in the same serverCron tick as the disconnect loop (src/replication.c:5348), closing the (full sync) window before it can fire. The timed-out replica is by then already promoted via replicaPutOnline(), so it falls into the (streaming sync) branch (src/replication.c:5357-5364). Linux CI does not hit this because SIGSTOP back-pressure keeps the RDB child blocked on the pipe write long enough that backgroundSaveDoneHandler does not run in the same tick. Accept either timeout-disconnect message and assert exactly one such disconnect occurred, so the test still rejects a regression that emits zero or multiple timeouts. This follows the existing catch+fallback convention already used in the same test for "all" and "slow" subcases (replication.tcl:1011-1036). Also addresses CodeRabbit feedback by adding a descriptive failure message to the `assert_equal 1 [count_log_message ...]` guard so a regression that emits zero or multiple timeout-disconnect log lines surfaces with context instead of a bare `Expected '1' to be equal to '0'`. Fixes #3686. Signed-off-by: Taeknology <20297177+Taeknology@users.noreply.github.com>
1 parent 8274099 commit 95849c9

1 file changed

Lines changed: 23 additions & 1 deletion

File tree

tests/integration/replication.tcl

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -973,8 +973,30 @@ start_server {tags {"repl external:skip"} overrides {save ""}} {
973973
# Let one replica hit repl-timeout while the slow reader
974974
# is paused, then restore a generous timeout so the
975975
# remaining replica can finish the streamed RDB.
976+
#
977+
# The disconnect can land in either of two branches in
978+
# replication.c serverCron (see src/replication.c around
979+
# the "Disconnecting timedout replica" emitters):
980+
# - "(full sync)" WAIT_BGSAVE_END + rdb_child_type == SOCKET
981+
# - "(streaming sync)" REPLICA_STATE_ONLINE
982+
# On some platforms (notably macOS CI) the RDB child can
983+
# exit and clear rdb_child_type in the same serverCron
984+
# tick as the disconnect check, closing the (full sync)
985+
# window; the timed-out replica is by then already
986+
# promoted via replicaPutOnline() and the disconnect
987+
# surfaces on the (streaming sync) path instead. Both
988+
# are legitimate timeout-driven disconnects.
976989
$master config set repl-timeout 2
977-
wait_for_log_messages -2 {"*Disconnecting timedout replica (full sync)*"} $loglines 100 100
990+
if {[catch {
991+
wait_for_log_messages -2 {"*Disconnecting timedout replica (full sync)*"} $loglines 100 100
992+
}]} {
993+
wait_for_log_messages -2 {"*Disconnecting timedout replica (streaming sync)*"} $loglines 100 100
994+
}
995+
# Guard against silently broadening the assertion: the
996+
# slow replica must time out exactly once across both
997+
# branches in this subcase.
998+
assert_equal 1 [count_log_message -2 "Disconnecting timedout replica"] \
999+
"expected exactly one 'Disconnecting timedout replica' log entry (full sync or streaming sync) for the slow replica"
9781000
$master config set repl-timeout 60
9791001
}
9801002

0 commit comments

Comments
 (0)