Repository navigation
Deflake diskless timeout rdb pipe test by tolerating either timeout-disconnect branch - #3772
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughThe test for diskless RDB pipe timeout handling now accepts either full-sync or streaming-sync disconnect logs, checks that the timedout replica log appears once, and restores ChangesTimeout disconnection test robustness
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Suggested reviewers
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@tests/integration/replication.tcl`:
- Line 998: Update the failing test assertion so it provides a descriptive error
message: change the assert_equal that compares 1 with the result of
count_log_message(... "Disconnecting timedout replica") to include a clear
message explaining the expectation (e.g., that exactly one "Disconnecting
timedout replica" log entry should be present). Locate the assertion using the
assert_equal call and the count_log_message invocation and add the descriptive
string as the assertion's message argument.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 183ac616-8bc0-4e1b-a69e-330ce23c468a
📒 Files selected for processing (1)
tests/integration/replication.tcl
…isconnect 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 valkey-io#3686. Signed-off-by: Taeknology <[email protected]>
93eac07 to
95849c9
Compare
rainsupreme
left a comment
There was a problem hiding this comment.
Looks pretty solid 👍
I might like to see a workflow that ran this 100x to show it isn't flaky any more, but your in-depth analysis convinces me that this is understood and worth fixing
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## unstable #3772 +/- ##
============================================
+ Coverage 76.73% 76.75% +0.02%
============================================
Files 162 162
Lines 81029 81029
============================================
+ Hits 62175 62196 +21
+ Misses 18854 18833 -21 🚀 New features to boost your workflow:
|
sarthakaggarwal97
left a comment
There was a problem hiding this comment.
The deep dive looks good and the change makes sense, I just have a minor comment.
sarthakaggarwal97
left a comment
There was a problem hiding this comment.
Also, it would be good to run it 100 times as well. As I mentioned here too - #3764 (review)
Use a single multi-pattern wait_for_log_messages for the "(full sync)" and "(streaming sync)" cases, as suggested in review. Keep the assert_equal count guard. Signed-off-by: Taeknology <[email protected]>
|
Thanks @sarthakaggarwal97 and @rainsupreme for all the guidance — I'm not very familiar with the contribution process yet, so it was really helpful. Ran the test 100 times locally — all 100 passed, no failures. |
|
Thanks @sarthakaggarwal97 for merging, and @rainsupreme @enjoy-binbin for the reviews. |
…isconnect branch (valkey-io#3772) Fixes valkey-io#3686. ### Symptom `tests/integration/replication.tcl` "diskless timeout replicas drop during rdb pipe" fails on `test-macos-latest`: ``` log message of '"*Disconnecting timedout replica (full sync)*"' not found in ./tests/tmp/server.13581.2852/stdout after line: 128 till line: 151 ``` The master *did* fire a timeout disconnect, but on the streaming-sync branch instead of the full-sync one: ``` 01:58:34.346 * Streamed RDB transfer with replica 127.0.0.1:22549 succeeded (socket). 01:58:34.346 * Synchronization with replica 127.0.0.1:22549 succeeded 01:58:37.373 # Disconnecting timedout replica (streaming sync): 127.0.0.1:22548 ``` ### Root cause: same-tick cron ordering `serverCron` does two things in the same tick that compete here: 1. `checkChildrenDone` (`src/server.c:1453`) reaps the RDB child and calls `backgroundSaveDoneHandler`, which clears `server.rdb_child_type = RDB_CHILD_TYPE_NONE` at `src/rdb.c:3698`. 2. The disconnect loop at `src/replication.c:5348` runs. The `(full sync)` branch (`src/replication.c:5369-5377`) is gated on `rdb_child_type == RDB_CHILD_TYPE_SOCKET`. Once step 1 clears it, the branch is unreachable for the rest of that tick. The SIGSTOP'd replica meanwhile was already promoted via `replicaPutOnline()` (`src/replication.c:2006-2031`), so the disconnect lands in the `(streaming sync)` branch at `src/replication.c:5357-5364` instead. On Linux CI, SIGSTOP back-pressure keeps the RDB child blocked on `write()` to the parent pipe long enough that step 1 does not run in the same tick as step 2. On macOS-latest CI the child drains faster (larger loopback `SO_SNDBUF`, different scheduler quanta), so the two events collapse into one tick and the test's strict `(full sync)` wait never matches. ### Fix Accept either timeout-disconnect message, then assert exactly one such disconnect occurred so the test still rejects a regression that emits zero or multiple timeouts: ```tcl if {[catch { wait_for_log_messages -2 {"*Disconnecting timedout replica (full sync)*"} $loglines 100 100 }]} { wait_for_log_messages -2 {"*Disconnecting timedout replica (streaming sync)*"} $loglines 100 100 } assert_equal 1 [count_log_message -2 "Disconnecting timedout replica"] ``` Both branches represent a legitimate timeout-driven disconnect; the test's intent ("the slow replica is dropped because of `repl-timeout`") is preserved. The `count_log_message` assertion guards against silently widening to "any timeout anywhere". ### Prior art in this test The same `catch { wait_for_log_messages ... }` + fallback pattern is already the established convention in this very test block to absorb RDB-pipe race variance — see the post-disconnect assertions for `all_drop == "all"` and `all_drop == "slow"` at `tests/integration/replication.tcl:1011-1036`. The comment ("RDB finished before replicas were killed; accept either 1 or 2 replicas still up at pipe-read time.") describes the same kind of timing variance this PR addresses for the timeout subcase on the disconnect-emission side. ### Alternatives considered - **Synchronize `pause_process` on partial-write evidence**: rejected. Once `rdb_child_type` is cleared in the same tick, no test-side synchronization can force the `(full sync)` path to fire. - **Diagnostic logging at `src/replication.c:5360,5373`** (state + `rdb_child_type` at disconnect): deferred to a separate follow-up PR. Useful for future triage but independent review surface, and this PR is intentionally test-only. ### Verification - `grep -n "Disconnecting timedout replica" src/replication.c` confirms both emitters intact (`:5360` streaming, `:5373` full). - `grep -rn "Disconnecting timedout replica (full sync)" tests/` confirms no other test relies on the strict string. - Full local run of `integration/replication` on macOS Apple Silicon: 111 passed, 0 failed. - 10-loop run of the five `diskless * replicas drop during rdb pipe` subcases (including timeout): 50/50 pass. The race is only reproducible on CI VM conditions, so local runs validate non-regression rather than fix efficacy. - Post-disconnect assertions at `replication.tcl:988-1080` (rdb_bgsave_in_progress, replicas_alive cleanup, dbsize parity, debug digest) are all branch-agnostic. --------- Signed-off-by: Taeknology <[email protected]> Co-authored-by: Sarthak Aggarwal <[email protected]> Signed-off-by: Vanshika <[email protected]>
…isconnect branch (valkey-io#3772) Fixes valkey-io#3686. ### Symptom `tests/integration/replication.tcl` "diskless timeout replicas drop during rdb pipe" fails on `test-macos-latest`: ``` log message of '"*Disconnecting timedout replica (full sync)*"' not found in ./tests/tmp/server.13581.2852/stdout after line: 128 till line: 151 ``` The master *did* fire a timeout disconnect, but on the streaming-sync branch instead of the full-sync one: ``` 01:58:34.346 * Streamed RDB transfer with replica 127.0.0.1:22549 succeeded (socket). 01:58:34.346 * Synchronization with replica 127.0.0.1:22549 succeeded 01:58:37.373 # Disconnecting timedout replica (streaming sync): 127.0.0.1:22548 ``` ### Root cause: same-tick cron ordering `serverCron` does two things in the same tick that compete here: 1. `checkChildrenDone` (`src/server.c:1453`) reaps the RDB child and calls `backgroundSaveDoneHandler`, which clears `server.rdb_child_type = RDB_CHILD_TYPE_NONE` at `src/rdb.c:3698`. 2. The disconnect loop at `src/replication.c:5348` runs. The `(full sync)` branch (`src/replication.c:5369-5377`) is gated on `rdb_child_type == RDB_CHILD_TYPE_SOCKET`. Once step 1 clears it, the branch is unreachable for the rest of that tick. The SIGSTOP'd replica meanwhile was already promoted via `replicaPutOnline()` (`src/replication.c:2006-2031`), so the disconnect lands in the `(streaming sync)` branch at `src/replication.c:5357-5364` instead. On Linux CI, SIGSTOP back-pressure keeps the RDB child blocked on `write()` to the parent pipe long enough that step 1 does not run in the same tick as step 2. On macOS-latest CI the child drains faster (larger loopback `SO_SNDBUF`, different scheduler quanta), so the two events collapse into one tick and the test's strict `(full sync)` wait never matches. ### Fix Accept either timeout-disconnect message, then assert exactly one such disconnect occurred so the test still rejects a regression that emits zero or multiple timeouts: ```tcl if {[catch { wait_for_log_messages -2 {"*Disconnecting timedout replica (full sync)*"} $loglines 100 100 }]} { wait_for_log_messages -2 {"*Disconnecting timedout replica (streaming sync)*"} $loglines 100 100 } assert_equal 1 [count_log_message -2 "Disconnecting timedout replica"] ``` Both branches represent a legitimate timeout-driven disconnect; the test's intent ("the slow replica is dropped because of `repl-timeout`") is preserved. The `count_log_message` assertion guards against silently widening to "any timeout anywhere". ### Prior art in this test The same `catch { wait_for_log_messages ... }` + fallback pattern is already the established convention in this very test block to absorb RDB-pipe race variance — see the post-disconnect assertions for `all_drop == "all"` and `all_drop == "slow"` at `tests/integration/replication.tcl:1011-1036`. The comment ("RDB finished before replicas were killed; accept either 1 or 2 replicas still up at pipe-read time.") describes the same kind of timing variance this PR addresses for the timeout subcase on the disconnect-emission side. ### Alternatives considered - **Synchronize `pause_process` on partial-write evidence**: rejected. Once `rdb_child_type` is cleared in the same tick, no test-side synchronization can force the `(full sync)` path to fire. - **Diagnostic logging at `src/replication.c:5360,5373`** (state + `rdb_child_type` at disconnect): deferred to a separate follow-up PR. Useful for future triage but independent review surface, and this PR is intentionally test-only. ### Verification - `grep -n "Disconnecting timedout replica" src/replication.c` confirms both emitters intact (`:5360` streaming, `:5373` full). - `grep -rn "Disconnecting timedout replica (full sync)" tests/` confirms no other test relies on the strict string. - Full local run of `integration/replication` on macOS Apple Silicon: 111 passed, 0 failed. - 10-loop run of the five `diskless * replicas drop during rdb pipe` subcases (including timeout): 50/50 pass. The race is only reproducible on CI VM conditions, so local runs validate non-regression rather than fix efficacy. - Post-disconnect assertions at `replication.tcl:988-1080` (rdb_bgsave_in_progress, replicas_alive cleanup, dbsize parity, debug digest) are all branch-agnostic. --------- Signed-off-by: Taeknology <[email protected]> Co-authored-by: Sarthak Aggarwal <[email protected]> Signed-off-by: Alon Arenberg <[email protected]>
…isconnect branch (valkey-io#3772) Fixes valkey-io#3686. ### Symptom `tests/integration/replication.tcl` "diskless timeout replicas drop during rdb pipe" fails on `test-macos-latest`: ``` log message of '"*Disconnecting timedout replica (full sync)*"' not found in ./tests/tmp/server.13581.2852/stdout after line: 128 till line: 151 ``` The master *did* fire a timeout disconnect, but on the streaming-sync branch instead of the full-sync one: ``` 01:58:34.346 * Streamed RDB transfer with replica 127.0.0.1:22549 succeeded (socket). 01:58:34.346 * Synchronization with replica 127.0.0.1:22549 succeeded 01:58:37.373 # Disconnecting timedout replica (streaming sync): 127.0.0.1:22548 ``` ### Root cause: same-tick cron ordering `serverCron` does two things in the same tick that compete here: 1. `checkChildrenDone` (`src/server.c:1453`) reaps the RDB child and calls `backgroundSaveDoneHandler`, which clears `server.rdb_child_type = RDB_CHILD_TYPE_NONE` at `src/rdb.c:3698`. 2. The disconnect loop at `src/replication.c:5348` runs. The `(full sync)` branch (`src/replication.c:5369-5377`) is gated on `rdb_child_type == RDB_CHILD_TYPE_SOCKET`. Once step 1 clears it, the branch is unreachable for the rest of that tick. The SIGSTOP'd replica meanwhile was already promoted via `replicaPutOnline()` (`src/replication.c:2006-2031`), so the disconnect lands in the `(streaming sync)` branch at `src/replication.c:5357-5364` instead. On Linux CI, SIGSTOP back-pressure keeps the RDB child blocked on `write()` to the parent pipe long enough that step 1 does not run in the same tick as step 2. On macOS-latest CI the child drains faster (larger loopback `SO_SNDBUF`, different scheduler quanta), so the two events collapse into one tick and the test's strict `(full sync)` wait never matches. ### Fix Accept either timeout-disconnect message, then assert exactly one such disconnect occurred so the test still rejects a regression that emits zero or multiple timeouts: ```tcl if {[catch { wait_for_log_messages -2 {"*Disconnecting timedout replica (full sync)*"} $loglines 100 100 }]} { wait_for_log_messages -2 {"*Disconnecting timedout replica (streaming sync)*"} $loglines 100 100 } assert_equal 1 [count_log_message -2 "Disconnecting timedout replica"] ``` Both branches represent a legitimate timeout-driven disconnect; the test's intent ("the slow replica is dropped because of `repl-timeout`") is preserved. The `count_log_message` assertion guards against silently widening to "any timeout anywhere". ### Prior art in this test The same `catch { wait_for_log_messages ... }` + fallback pattern is already the established convention in this very test block to absorb RDB-pipe race variance — see the post-disconnect assertions for `all_drop == "all"` and `all_drop == "slow"` at `tests/integration/replication.tcl:1011-1036`. The comment ("RDB finished before replicas were killed; accept either 1 or 2 replicas still up at pipe-read time.") describes the same kind of timing variance this PR addresses for the timeout subcase on the disconnect-emission side. ### Alternatives considered - **Synchronize `pause_process` on partial-write evidence**: rejected. Once `rdb_child_type` is cleared in the same tick, no test-side synchronization can force the `(full sync)` path to fire. - **Diagnostic logging at `src/replication.c:5360,5373`** (state + `rdb_child_type` at disconnect): deferred to a separate follow-up PR. Useful for future triage but independent review surface, and this PR is intentionally test-only. ### Verification - `grep -n "Disconnecting timedout replica" src/replication.c` confirms both emitters intact (`:5360` streaming, `:5373` full). - `grep -rn "Disconnecting timedout replica (full sync)" tests/` confirms no other test relies on the strict string. - Full local run of `integration/replication` on macOS Apple Silicon: 111 passed, 0 failed. - 10-loop run of the five `diskless * replicas drop during rdb pipe` subcases (including timeout): 50/50 pass. The race is only reproducible on CI VM conditions, so local runs validate non-regression rather than fix efficacy. - Post-disconnect assertions at `replication.tcl:988-1080` (rdb_bgsave_in_progress, replicas_alive cleanup, dbsize parity, debug digest) are all branch-agnostic. --------- Signed-off-by: Taeknology <[email protected]> Co-authored-by: Sarthak Aggarwal <[email protected]> Signed-off-by: Alon Arenberg <[email protected]>
…isconnect branch (#3772) Fixes #3686. ### Symptom `tests/integration/replication.tcl` "diskless timeout replicas drop during rdb pipe" fails on `test-macos-latest`: ``` log message of '"*Disconnecting timedout replica (full sync)*"' not found in ./tests/tmp/server.13581.2852/stdout after line: 128 till line: 151 ``` The master *did* fire a timeout disconnect, but on the streaming-sync branch instead of the full-sync one: ``` 01:58:34.346 * Streamed RDB transfer with replica 127.0.0.1:22549 succeeded (socket). 01:58:34.346 * Synchronization with replica 127.0.0.1:22549 succeeded 01:58:37.373 # Disconnecting timedout replica (streaming sync): 127.0.0.1:22548 ``` ### Root cause: same-tick cron ordering `serverCron` does two things in the same tick that compete here: 1. `checkChildrenDone` (`src/server.c:1453`) reaps the RDB child and calls `backgroundSaveDoneHandler`, which clears `server.rdb_child_type = RDB_CHILD_TYPE_NONE` at `src/rdb.c:3698`. 2. The disconnect loop at `src/replication.c:5348` runs. The `(full sync)` branch (`src/replication.c:5369-5377`) is gated on `rdb_child_type == RDB_CHILD_TYPE_SOCKET`. Once step 1 clears it, the branch is unreachable for the rest of that tick. The SIGSTOP'd replica meanwhile was already promoted via `replicaPutOnline()` (`src/replication.c:2006-2031`), so the disconnect lands in the `(streaming sync)` branch at `src/replication.c:5357-5364` instead. On Linux CI, SIGSTOP back-pressure keeps the RDB child blocked on `write()` to the parent pipe long enough that step 1 does not run in the same tick as step 2. On macOS-latest CI the child drains faster (larger loopback `SO_SNDBUF`, different scheduler quanta), so the two events collapse into one tick and the test's strict `(full sync)` wait never matches. ### Fix Accept either timeout-disconnect message, then assert exactly one such disconnect occurred so the test still rejects a regression that emits zero or multiple timeouts: ```tcl if {[catch { wait_for_log_messages -2 {"*Disconnecting timedout replica (full sync)*"} $loglines 100 100 }]} { wait_for_log_messages -2 {"*Disconnecting timedout replica (streaming sync)*"} $loglines 100 100 } assert_equal 1 [count_log_message -2 "Disconnecting timedout replica"] ``` Both branches represent a legitimate timeout-driven disconnect; the test's intent ("the slow replica is dropped because of `repl-timeout`") is preserved. The `count_log_message` assertion guards against silently widening to "any timeout anywhere". ### Prior art in this test The same `catch { wait_for_log_messages ... }` + fallback pattern is already the established convention in this very test block to absorb RDB-pipe race variance — see the post-disconnect assertions for `all_drop == "all"` and `all_drop == "slow"` at `tests/integration/replication.tcl:1011-1036`. The comment ("RDB finished before replicas were killed; accept either 1 or 2 replicas still up at pipe-read time.") describes the same kind of timing variance this PR addresses for the timeout subcase on the disconnect-emission side. ### Alternatives considered - **Synchronize `pause_process` on partial-write evidence**: rejected. Once `rdb_child_type` is cleared in the same tick, no test-side synchronization can force the `(full sync)` path to fire. - **Diagnostic logging at `src/replication.c:5360,5373`** (state + `rdb_child_type` at disconnect): deferred to a separate follow-up PR. Useful for future triage but independent review surface, and this PR is intentionally test-only. ### Verification - `grep -n "Disconnecting timedout replica" src/replication.c` confirms both emitters intact (`:5360` streaming, `:5373` full). - `grep -rn "Disconnecting timedout replica (full sync)" tests/` confirms no other test relies on the strict string. - Full local run of `integration/replication` on macOS Apple Silicon: 111 passed, 0 failed. - 10-loop run of the five `diskless * replicas drop during rdb pipe` subcases (including timeout): 50/50 pass. The race is only reproducible on CI VM conditions, so local runs validate non-regression rather than fix efficacy. - Post-disconnect assertions at `replication.tcl:988-1080` (rdb_bgsave_in_progress, replicas_alive cleanup, dbsize parity, debug digest) are all branch-agnostic. --------- Signed-off-by: Taeknology <[email protected]> Co-authored-by: Sarthak Aggarwal <[email protected]> Backport-Source-PR: 3772
…isconnect branch (#3772) Fixes #3686. ### Symptom `tests/integration/replication.tcl` "diskless timeout replicas drop during rdb pipe" fails on `test-macos-latest`: ``` log message of '"*Disconnecting timedout replica (full sync)*"' not found in ./tests/tmp/server.13581.2852/stdout after line: 128 till line: 151 ``` The master *did* fire a timeout disconnect, but on the streaming-sync branch instead of the full-sync one: ``` 01:58:34.346 * Streamed RDB transfer with replica 127.0.0.1:22549 succeeded (socket). 01:58:34.346 * Synchronization with replica 127.0.0.1:22549 succeeded 01:58:37.373 # Disconnecting timedout replica (streaming sync): 127.0.0.1:22548 ``` ### Root cause: same-tick cron ordering `serverCron` does two things in the same tick that compete here: 1. `checkChildrenDone` (`src/server.c:1453`) reaps the RDB child and calls `backgroundSaveDoneHandler`, which clears `server.rdb_child_type = RDB_CHILD_TYPE_NONE` at `src/rdb.c:3698`. 2. The disconnect loop at `src/replication.c:5348` runs. The `(full sync)` branch (`src/replication.c:5369-5377`) is gated on `rdb_child_type == RDB_CHILD_TYPE_SOCKET`. Once step 1 clears it, the branch is unreachable for the rest of that tick. The SIGSTOP'd replica meanwhile was already promoted via `replicaPutOnline()` (`src/replication.c:2006-2031`), so the disconnect lands in the `(streaming sync)` branch at `src/replication.c:5357-5364` instead. On Linux CI, SIGSTOP back-pressure keeps the RDB child blocked on `write()` to the parent pipe long enough that step 1 does not run in the same tick as step 2. On macOS-latest CI the child drains faster (larger loopback `SO_SNDBUF`, different scheduler quanta), so the two events collapse into one tick and the test's strict `(full sync)` wait never matches. ### Fix Accept either timeout-disconnect message, then assert exactly one such disconnect occurred so the test still rejects a regression that emits zero or multiple timeouts: ```tcl if {[catch { wait_for_log_messages -2 {"*Disconnecting timedout replica (full sync)*"} $loglines 100 100 }]} { wait_for_log_messages -2 {"*Disconnecting timedout replica (streaming sync)*"} $loglines 100 100 } assert_equal 1 [count_log_message -2 "Disconnecting timedout replica"] ``` Both branches represent a legitimate timeout-driven disconnect; the test's intent ("the slow replica is dropped because of `repl-timeout`") is preserved. The `count_log_message` assertion guards against silently widening to "any timeout anywhere". ### Prior art in this test The same `catch { wait_for_log_messages ... }` + fallback pattern is already the established convention in this very test block to absorb RDB-pipe race variance — see the post-disconnect assertions for `all_drop == "all"` and `all_drop == "slow"` at `tests/integration/replication.tcl:1011-1036`. The comment ("RDB finished before replicas were killed; accept either 1 or 2 replicas still up at pipe-read time.") describes the same kind of timing variance this PR addresses for the timeout subcase on the disconnect-emission side. ### Alternatives considered - **Synchronize `pause_process` on partial-write evidence**: rejected. Once `rdb_child_type` is cleared in the same tick, no test-side synchronization can force the `(full sync)` path to fire. - **Diagnostic logging at `src/replication.c:5360,5373`** (state + `rdb_child_type` at disconnect): deferred to a separate follow-up PR. Useful for future triage but independent review surface, and this PR is intentionally test-only. ### Verification - `grep -n "Disconnecting timedout replica" src/replication.c` confirms both emitters intact (`:5360` streaming, `:5373` full). - `grep -rn "Disconnecting timedout replica (full sync)" tests/` confirms no other test relies on the strict string. - Full local run of `integration/replication` on macOS Apple Silicon: 111 passed, 0 failed. - 10-loop run of the five `diskless * replicas drop during rdb pipe` subcases (including timeout): 50/50 pass. The race is only reproducible on CI VM conditions, so local runs validate non-regression rather than fix efficacy. - Post-disconnect assertions at `replication.tcl:988-1080` (rdb_bgsave_in_progress, replicas_alive cleanup, dbsize parity, debug digest) are all branch-agnostic. --------- Signed-off-by: Taeknology <[email protected]> Co-authored-by: Sarthak Aggarwal <[email protected]> Backport-Source-PR: 3772
…isconnect branch (#3772) Fixes #3686. ### Symptom `tests/integration/replication.tcl` "diskless timeout replicas drop during rdb pipe" fails on `test-macos-latest`: ``` log message of '"*Disconnecting timedout replica (full sync)*"' not found in ./tests/tmp/server.13581.2852/stdout after line: 128 till line: 151 ``` The master *did* fire a timeout disconnect, but on the streaming-sync branch instead of the full-sync one: ``` 01:58:34.346 * Streamed RDB transfer with replica 127.0.0.1:22549 succeeded (socket). 01:58:34.346 * Synchronization with replica 127.0.0.1:22549 succeeded 01:58:37.373 # Disconnecting timedout replica (streaming sync): 127.0.0.1:22548 ``` ### Root cause: same-tick cron ordering `serverCron` does two things in the same tick that compete here: 1. `checkChildrenDone` (`src/server.c:1453`) reaps the RDB child and calls `backgroundSaveDoneHandler`, which clears `server.rdb_child_type = RDB_CHILD_TYPE_NONE` at `src/rdb.c:3698`. 2. The disconnect loop at `src/replication.c:5348` runs. The `(full sync)` branch (`src/replication.c:5369-5377`) is gated on `rdb_child_type == RDB_CHILD_TYPE_SOCKET`. Once step 1 clears it, the branch is unreachable for the rest of that tick. The SIGSTOP'd replica meanwhile was already promoted via `replicaPutOnline()` (`src/replication.c:2006-2031`), so the disconnect lands in the `(streaming sync)` branch at `src/replication.c:5357-5364` instead. On Linux CI, SIGSTOP back-pressure keeps the RDB child blocked on `write()` to the parent pipe long enough that step 1 does not run in the same tick as step 2. On macOS-latest CI the child drains faster (larger loopback `SO_SNDBUF`, different scheduler quanta), so the two events collapse into one tick and the test's strict `(full sync)` wait never matches. ### Fix Accept either timeout-disconnect message, then assert exactly one such disconnect occurred so the test still rejects a regression that emits zero or multiple timeouts: ```tcl if {[catch { wait_for_log_messages -2 {"*Disconnecting timedout replica (full sync)*"} $loglines 100 100 }]} { wait_for_log_messages -2 {"*Disconnecting timedout replica (streaming sync)*"} $loglines 100 100 } assert_equal 1 [count_log_message -2 "Disconnecting timedout replica"] ``` Both branches represent a legitimate timeout-driven disconnect; the test's intent ("the slow replica is dropped because of `repl-timeout`") is preserved. The `count_log_message` assertion guards against silently widening to "any timeout anywhere". ### Prior art in this test The same `catch { wait_for_log_messages ... }` + fallback pattern is already the established convention in this very test block to absorb RDB-pipe race variance — see the post-disconnect assertions for `all_drop == "all"` and `all_drop == "slow"` at `tests/integration/replication.tcl:1011-1036`. The comment ("RDB finished before replicas were killed; accept either 1 or 2 replicas still up at pipe-read time.") describes the same kind of timing variance this PR addresses for the timeout subcase on the disconnect-emission side. ### Alternatives considered - **Synchronize `pause_process` on partial-write evidence**: rejected. Once `rdb_child_type` is cleared in the same tick, no test-side synchronization can force the `(full sync)` path to fire. - **Diagnostic logging at `src/replication.c:5360,5373`** (state + `rdb_child_type` at disconnect): deferred to a separate follow-up PR. Useful for future triage but independent review surface, and this PR is intentionally test-only. ### Verification - `grep -n "Disconnecting timedout replica" src/replication.c` confirms both emitters intact (`:5360` streaming, `:5373` full). - `grep -rn "Disconnecting timedout replica (full sync)" tests/` confirms no other test relies on the strict string. - Full local run of `integration/replication` on macOS Apple Silicon: 111 passed, 0 failed. - 10-loop run of the five `diskless * replicas drop during rdb pipe` subcases (including timeout): 50/50 pass. The race is only reproducible on CI VM conditions, so local runs validate non-regression rather than fix efficacy. - Post-disconnect assertions at `replication.tcl:988-1080` (rdb_bgsave_in_progress, replicas_alive cleanup, dbsize parity, debug digest) are all branch-agnostic. --------- Signed-off-by: Taeknology <[email protected]> Co-authored-by: Sarthak Aggarwal <[email protected]> Backport-Source-PR: 3772
…isconnect branch (#3772) Fixes #3686. ### Symptom `tests/integration/replication.tcl` "diskless timeout replicas drop during rdb pipe" fails on `test-macos-latest`: ``` log message of '"*Disconnecting timedout replica (full sync)*"' not found in ./tests/tmp/server.13581.2852/stdout after line: 128 till line: 151 ``` The master *did* fire a timeout disconnect, but on the streaming-sync branch instead of the full-sync one: ``` 01:58:34.346 * Streamed RDB transfer with replica 127.0.0.1:22549 succeeded (socket). 01:58:34.346 * Synchronization with replica 127.0.0.1:22549 succeeded 01:58:37.373 # Disconnecting timedout replica (streaming sync): 127.0.0.1:22548 ``` ### Root cause: same-tick cron ordering `serverCron` does two things in the same tick that compete here: 1. `checkChildrenDone` (`src/server.c:1453`) reaps the RDB child and calls `backgroundSaveDoneHandler`, which clears `server.rdb_child_type = RDB_CHILD_TYPE_NONE` at `src/rdb.c:3698`. 2. The disconnect loop at `src/replication.c:5348` runs. The `(full sync)` branch (`src/replication.c:5369-5377`) is gated on `rdb_child_type == RDB_CHILD_TYPE_SOCKET`. Once step 1 clears it, the branch is unreachable for the rest of that tick. The SIGSTOP'd replica meanwhile was already promoted via `replicaPutOnline()` (`src/replication.c:2006-2031`), so the disconnect lands in the `(streaming sync)` branch at `src/replication.c:5357-5364` instead. On Linux CI, SIGSTOP back-pressure keeps the RDB child blocked on `write()` to the parent pipe long enough that step 1 does not run in the same tick as step 2. On macOS-latest CI the child drains faster (larger loopback `SO_SNDBUF`, different scheduler quanta), so the two events collapse into one tick and the test's strict `(full sync)` wait never matches. ### Fix Accept either timeout-disconnect message, then assert exactly one such disconnect occurred so the test still rejects a regression that emits zero or multiple timeouts: ```tcl if {[catch { wait_for_log_messages -2 {"*Disconnecting timedout replica (full sync)*"} $loglines 100 100 }]} { wait_for_log_messages -2 {"*Disconnecting timedout replica (streaming sync)*"} $loglines 100 100 } assert_equal 1 [count_log_message -2 "Disconnecting timedout replica"] ``` Both branches represent a legitimate timeout-driven disconnect; the test's intent ("the slow replica is dropped because of `repl-timeout`") is preserved. The `count_log_message` assertion guards against silently widening to "any timeout anywhere". ### Prior art in this test The same `catch { wait_for_log_messages ... }` + fallback pattern is already the established convention in this very test block to absorb RDB-pipe race variance — see the post-disconnect assertions for `all_drop == "all"` and `all_drop == "slow"` at `tests/integration/replication.tcl:1011-1036`. The comment ("RDB finished before replicas were killed; accept either 1 or 2 replicas still up at pipe-read time.") describes the same kind of timing variance this PR addresses for the timeout subcase on the disconnect-emission side. ### Alternatives considered - **Synchronize `pause_process` on partial-write evidence**: rejected. Once `rdb_child_type` is cleared in the same tick, no test-side synchronization can force the `(full sync)` path to fire. - **Diagnostic logging at `src/replication.c:5360,5373`** (state + `rdb_child_type` at disconnect): deferred to a separate follow-up PR. Useful for future triage but independent review surface, and this PR is intentionally test-only. ### Verification - `grep -n "Disconnecting timedout replica" src/replication.c` confirms both emitters intact (`:5360` streaming, `:5373` full). - `grep -rn "Disconnecting timedout replica (full sync)" tests/` confirms no other test relies on the strict string. - Full local run of `integration/replication` on macOS Apple Silicon: 111 passed, 0 failed. - 10-loop run of the five `diskless * replicas drop during rdb pipe` subcases (including timeout): 50/50 pass. The race is only reproducible on CI VM conditions, so local runs validate non-regression rather than fix efficacy. - Post-disconnect assertions at `replication.tcl:988-1080` (rdb_bgsave_in_progress, replicas_alive cleanup, dbsize parity, debug digest) are all branch-agnostic. --------- Signed-off-by: Taeknology <[email protected]> Co-authored-by: Sarthak Aggarwal <[email protected]> Backport-Source-PR: 3772
…isconnect branch (#3772) Fixes #3686. ### Symptom `tests/integration/replication.tcl` "diskless timeout replicas drop during rdb pipe" fails on `test-macos-latest`: ``` log message of '"*Disconnecting timedout replica (full sync)*"' not found in ./tests/tmp/server.13581.2852/stdout after line: 128 till line: 151 ``` The master *did* fire a timeout disconnect, but on the streaming-sync branch instead of the full-sync one: ``` 01:58:34.346 * Streamed RDB transfer with replica 127.0.0.1:22549 succeeded (socket). 01:58:34.346 * Synchronization with replica 127.0.0.1:22549 succeeded 01:58:37.373 # Disconnecting timedout replica (streaming sync): 127.0.0.1:22548 ``` ### Root cause: same-tick cron ordering `serverCron` does two things in the same tick that compete here: 1. `checkChildrenDone` (`src/server.c:1453`) reaps the RDB child and calls `backgroundSaveDoneHandler`, which clears `server.rdb_child_type = RDB_CHILD_TYPE_NONE` at `src/rdb.c:3698`. 2. The disconnect loop at `src/replication.c:5348` runs. The `(full sync)` branch (`src/replication.c:5369-5377`) is gated on `rdb_child_type == RDB_CHILD_TYPE_SOCKET`. Once step 1 clears it, the branch is unreachable for the rest of that tick. The SIGSTOP'd replica meanwhile was already promoted via `replicaPutOnline()` (`src/replication.c:2006-2031`), so the disconnect lands in the `(streaming sync)` branch at `src/replication.c:5357-5364` instead. On Linux CI, SIGSTOP back-pressure keeps the RDB child blocked on `write()` to the parent pipe long enough that step 1 does not run in the same tick as step 2. On macOS-latest CI the child drains faster (larger loopback `SO_SNDBUF`, different scheduler quanta), so the two events collapse into one tick and the test's strict `(full sync)` wait never matches. ### Fix Accept either timeout-disconnect message, then assert exactly one such disconnect occurred so the test still rejects a regression that emits zero or multiple timeouts: ```tcl if {[catch { wait_for_log_messages -2 {"*Disconnecting timedout replica (full sync)*"} $loglines 100 100 }]} { wait_for_log_messages -2 {"*Disconnecting timedout replica (streaming sync)*"} $loglines 100 100 } assert_equal 1 [count_log_message -2 "Disconnecting timedout replica"] ``` Both branches represent a legitimate timeout-driven disconnect; the test's intent ("the slow replica is dropped because of `repl-timeout`") is preserved. The `count_log_message` assertion guards against silently widening to "any timeout anywhere". ### Prior art in this test The same `catch { wait_for_log_messages ... }` + fallback pattern is already the established convention in this very test block to absorb RDB-pipe race variance — see the post-disconnect assertions for `all_drop == "all"` and `all_drop == "slow"` at `tests/integration/replication.tcl:1011-1036`. The comment ("RDB finished before replicas were killed; accept either 1 or 2 replicas still up at pipe-read time.") describes the same kind of timing variance this PR addresses for the timeout subcase on the disconnect-emission side. ### Alternatives considered - **Synchronize `pause_process` on partial-write evidence**: rejected. Once `rdb_child_type` is cleared in the same tick, no test-side synchronization can force the `(full sync)` path to fire. - **Diagnostic logging at `src/replication.c:5360,5373`** (state + `rdb_child_type` at disconnect): deferred to a separate follow-up PR. Useful for future triage but independent review surface, and this PR is intentionally test-only. ### Verification - `grep -n "Disconnecting timedout replica" src/replication.c` confirms both emitters intact (`:5360` streaming, `:5373` full). - `grep -rn "Disconnecting timedout replica (full sync)" tests/` confirms no other test relies on the strict string. - Full local run of `integration/replication` on macOS Apple Silicon: 111 passed, 0 failed. - 10-loop run of the five `diskless * replicas drop during rdb pipe` subcases (including timeout): 50/50 pass. The race is only reproducible on CI VM conditions, so local runs validate non-regression rather than fix efficacy. - Post-disconnect assertions at `replication.tcl:988-1080` (rdb_bgsave_in_progress, replicas_alive cleanup, dbsize parity, debug digest) are all branch-agnostic. --------- Signed-off-by: Taeknology <[email protected]> Co-authored-by: Sarthak Aggarwal <[email protected]> Backport-Source-PR: 3772
…isconnect branch (#3772) Fixes #3686. ### Symptom `tests/integration/replication.tcl` "diskless timeout replicas drop during rdb pipe" fails on `test-macos-latest`: ``` log message of '"*Disconnecting timedout replica (full sync)*"' not found in ./tests/tmp/server.13581.2852/stdout after line: 128 till line: 151 ``` The master *did* fire a timeout disconnect, but on the streaming-sync branch instead of the full-sync one: ``` 01:58:34.346 * Streamed RDB transfer with replica 127.0.0.1:22549 succeeded (socket). 01:58:34.346 * Synchronization with replica 127.0.0.1:22549 succeeded 01:58:37.373 # Disconnecting timedout replica (streaming sync): 127.0.0.1:22548 ``` ### Root cause: same-tick cron ordering `serverCron` does two things in the same tick that compete here: 1. `checkChildrenDone` (`src/server.c:1453`) reaps the RDB child and calls `backgroundSaveDoneHandler`, which clears `server.rdb_child_type = RDB_CHILD_TYPE_NONE` at `src/rdb.c:3698`. 2. The disconnect loop at `src/replication.c:5348` runs. The `(full sync)` branch (`src/replication.c:5369-5377`) is gated on `rdb_child_type == RDB_CHILD_TYPE_SOCKET`. Once step 1 clears it, the branch is unreachable for the rest of that tick. The SIGSTOP'd replica meanwhile was already promoted via `replicaPutOnline()` (`src/replication.c:2006-2031`), so the disconnect lands in the `(streaming sync)` branch at `src/replication.c:5357-5364` instead. On Linux CI, SIGSTOP back-pressure keeps the RDB child blocked on `write()` to the parent pipe long enough that step 1 does not run in the same tick as step 2. On macOS-latest CI the child drains faster (larger loopback `SO_SNDBUF`, different scheduler quanta), so the two events collapse into one tick and the test's strict `(full sync)` wait never matches. ### Fix Accept either timeout-disconnect message, then assert exactly one such disconnect occurred so the test still rejects a regression that emits zero or multiple timeouts: ```tcl if {[catch { wait_for_log_messages -2 {"*Disconnecting timedout replica (full sync)*"} $loglines 100 100 }]} { wait_for_log_messages -2 {"*Disconnecting timedout replica (streaming sync)*"} $loglines 100 100 } assert_equal 1 [count_log_message -2 "Disconnecting timedout replica"] ``` Both branches represent a legitimate timeout-driven disconnect; the test's intent ("the slow replica is dropped because of `repl-timeout`") is preserved. The `count_log_message` assertion guards against silently widening to "any timeout anywhere". ### Prior art in this test The same `catch { wait_for_log_messages ... }` + fallback pattern is already the established convention in this very test block to absorb RDB-pipe race variance — see the post-disconnect assertions for `all_drop == "all"` and `all_drop == "slow"` at `tests/integration/replication.tcl:1011-1036`. The comment ("RDB finished before replicas were killed; accept either 1 or 2 replicas still up at pipe-read time.") describes the same kind of timing variance this PR addresses for the timeout subcase on the disconnect-emission side. ### Alternatives considered - **Synchronize `pause_process` on partial-write evidence**: rejected. Once `rdb_child_type` is cleared in the same tick, no test-side synchronization can force the `(full sync)` path to fire. - **Diagnostic logging at `src/replication.c:5360,5373`** (state + `rdb_child_type` at disconnect): deferred to a separate follow-up PR. Useful for future triage but independent review surface, and this PR is intentionally test-only. ### Verification - `grep -n "Disconnecting timedout replica" src/replication.c` confirms both emitters intact (`:5360` streaming, `:5373` full). - `grep -rn "Disconnecting timedout replica (full sync)" tests/` confirms no other test relies on the strict string. - Full local run of `integration/replication` on macOS Apple Silicon: 111 passed, 0 failed. - 10-loop run of the five `diskless * replicas drop during rdb pipe` subcases (including timeout): 50/50 pass. The race is only reproducible on CI VM conditions, so local runs validate non-regression rather than fix efficacy. - Post-disconnect assertions at `replication.tcl:988-1080` (rdb_bgsave_in_progress, replicas_alive cleanup, dbsize parity, debug digest) are all branch-agnostic. --------- Signed-off-by: Taeknology <[email protected]> Co-authored-by: Sarthak Aggarwal <[email protected]> Backport-Source-PR: 3772
…isconnect branch (#3772) Fixes #3686. ### Symptom `tests/integration/replication.tcl` "diskless timeout replicas drop during rdb pipe" fails on `test-macos-latest`: ``` log message of '"*Disconnecting timedout replica (full sync)*"' not found in ./tests/tmp/server.13581.2852/stdout after line: 128 till line: 151 ``` The master *did* fire a timeout disconnect, but on the streaming-sync branch instead of the full-sync one: ``` 01:58:34.346 * Streamed RDB transfer with replica 127.0.0.1:22549 succeeded (socket). 01:58:34.346 * Synchronization with replica 127.0.0.1:22549 succeeded 01:58:37.373 # Disconnecting timedout replica (streaming sync): 127.0.0.1:22548 ``` ### Root cause: same-tick cron ordering `serverCron` does two things in the same tick that compete here: 1. `checkChildrenDone` (`src/server.c:1453`) reaps the RDB child and calls `backgroundSaveDoneHandler`, which clears `server.rdb_child_type = RDB_CHILD_TYPE_NONE` at `src/rdb.c:3698`. 2. The disconnect loop at `src/replication.c:5348` runs. The `(full sync)` branch (`src/replication.c:5369-5377`) is gated on `rdb_child_type == RDB_CHILD_TYPE_SOCKET`. Once step 1 clears it, the branch is unreachable for the rest of that tick. The SIGSTOP'd replica meanwhile was already promoted via `replicaPutOnline()` (`src/replication.c:2006-2031`), so the disconnect lands in the `(streaming sync)` branch at `src/replication.c:5357-5364` instead. On Linux CI, SIGSTOP back-pressure keeps the RDB child blocked on `write()` to the parent pipe long enough that step 1 does not run in the same tick as step 2. On macOS-latest CI the child drains faster (larger loopback `SO_SNDBUF`, different scheduler quanta), so the two events collapse into one tick and the test's strict `(full sync)` wait never matches. ### Fix Accept either timeout-disconnect message, then assert exactly one such disconnect occurred so the test still rejects a regression that emits zero or multiple timeouts: ```tcl if {[catch { wait_for_log_messages -2 {"*Disconnecting timedout replica (full sync)*"} $loglines 100 100 }]} { wait_for_log_messages -2 {"*Disconnecting timedout replica (streaming sync)*"} $loglines 100 100 } assert_equal 1 [count_log_message -2 "Disconnecting timedout replica"] ``` Both branches represent a legitimate timeout-driven disconnect; the test's intent ("the slow replica is dropped because of `repl-timeout`") is preserved. The `count_log_message` assertion guards against silently widening to "any timeout anywhere". ### Prior art in this test The same `catch { wait_for_log_messages ... }` + fallback pattern is already the established convention in this very test block to absorb RDB-pipe race variance — see the post-disconnect assertions for `all_drop == "all"` and `all_drop == "slow"` at `tests/integration/replication.tcl:1011-1036`. The comment ("RDB finished before replicas were killed; accept either 1 or 2 replicas still up at pipe-read time.") describes the same kind of timing variance this PR addresses for the timeout subcase on the disconnect-emission side. ### Alternatives considered - **Synchronize `pause_process` on partial-write evidence**: rejected. Once `rdb_child_type` is cleared in the same tick, no test-side synchronization can force the `(full sync)` path to fire. - **Diagnostic logging at `src/replication.c:5360,5373`** (state + `rdb_child_type` at disconnect): deferred to a separate follow-up PR. Useful for future triage but independent review surface, and this PR is intentionally test-only. ### Verification - `grep -n "Disconnecting timedout replica" src/replication.c` confirms both emitters intact (`:5360` streaming, `:5373` full). - `grep -rn "Disconnecting timedout replica (full sync)" tests/` confirms no other test relies on the strict string. - Full local run of `integration/replication` on macOS Apple Silicon: 111 passed, 0 failed. - 10-loop run of the five `diskless * replicas drop during rdb pipe` subcases (including timeout): 50/50 pass. The race is only reproducible on CI VM conditions, so local runs validate non-regression rather than fix efficacy. - Post-disconnect assertions at `replication.tcl:988-1080` (rdb_bgsave_in_progress, replicas_alive cleanup, dbsize parity, debug digest) are all branch-agnostic. --------- Signed-off-by: Taeknology <[email protected]> Co-authored-by: Sarthak Aggarwal <[email protected]> Backport-Source-PR: 3772
…isconnect branch (#3772) Fixes #3686. ### Symptom `tests/integration/replication.tcl` "diskless timeout replicas drop during rdb pipe" fails on `test-macos-latest`: ``` log message of '"*Disconnecting timedout replica (full sync)*"' not found in ./tests/tmp/server.13581.2852/stdout after line: 128 till line: 151 ``` The master *did* fire a timeout disconnect, but on the streaming-sync branch instead of the full-sync one: ``` 01:58:34.346 * Streamed RDB transfer with replica 127.0.0.1:22549 succeeded (socket). 01:58:34.346 * Synchronization with replica 127.0.0.1:22549 succeeded 01:58:37.373 # Disconnecting timedout replica (streaming sync): 127.0.0.1:22548 ``` ### Root cause: same-tick cron ordering `serverCron` does two things in the same tick that compete here: 1. `checkChildrenDone` (`src/server.c:1453`) reaps the RDB child and calls `backgroundSaveDoneHandler`, which clears `server.rdb_child_type = RDB_CHILD_TYPE_NONE` at `src/rdb.c:3698`. 2. The disconnect loop at `src/replication.c:5348` runs. The `(full sync)` branch (`src/replication.c:5369-5377`) is gated on `rdb_child_type == RDB_CHILD_TYPE_SOCKET`. Once step 1 clears it, the branch is unreachable for the rest of that tick. The SIGSTOP'd replica meanwhile was already promoted via `replicaPutOnline()` (`src/replication.c:2006-2031`), so the disconnect lands in the `(streaming sync)` branch at `src/replication.c:5357-5364` instead. On Linux CI, SIGSTOP back-pressure keeps the RDB child blocked on `write()` to the parent pipe long enough that step 1 does not run in the same tick as step 2. On macOS-latest CI the child drains faster (larger loopback `SO_SNDBUF`, different scheduler quanta), so the two events collapse into one tick and the test's strict `(full sync)` wait never matches. ### Fix Accept either timeout-disconnect message, then assert exactly one such disconnect occurred so the test still rejects a regression that emits zero or multiple timeouts: ```tcl if {[catch { wait_for_log_messages -2 {"*Disconnecting timedout replica (full sync)*"} $loglines 100 100 }]} { wait_for_log_messages -2 {"*Disconnecting timedout replica (streaming sync)*"} $loglines 100 100 } assert_equal 1 [count_log_message -2 "Disconnecting timedout replica"] ``` Both branches represent a legitimate timeout-driven disconnect; the test's intent ("the slow replica is dropped because of `repl-timeout`") is preserved. The `count_log_message` assertion guards against silently widening to "any timeout anywhere". ### Prior art in this test The same `catch { wait_for_log_messages ... }` + fallback pattern is already the established convention in this very test block to absorb RDB-pipe race variance — see the post-disconnect assertions for `all_drop == "all"` and `all_drop == "slow"` at `tests/integration/replication.tcl:1011-1036`. The comment ("RDB finished before replicas were killed; accept either 1 or 2 replicas still up at pipe-read time.") describes the same kind of timing variance this PR addresses for the timeout subcase on the disconnect-emission side. ### Alternatives considered - **Synchronize `pause_process` on partial-write evidence**: rejected. Once `rdb_child_type` is cleared in the same tick, no test-side synchronization can force the `(full sync)` path to fire. - **Diagnostic logging at `src/replication.c:5360,5373`** (state + `rdb_child_type` at disconnect): deferred to a separate follow-up PR. Useful for future triage but independent review surface, and this PR is intentionally test-only. ### Verification - `grep -n "Disconnecting timedout replica" src/replication.c` confirms both emitters intact (`:5360` streaming, `:5373` full). - `grep -rn "Disconnecting timedout replica (full sync)" tests/` confirms no other test relies on the strict string. - Full local run of `integration/replication` on macOS Apple Silicon: 111 passed, 0 failed. - 10-loop run of the five `diskless * replicas drop during rdb pipe` subcases (including timeout): 50/50 pass. The race is only reproducible on CI VM conditions, so local runs validate non-regression rather than fix efficacy. - Post-disconnect assertions at `replication.tcl:988-1080` (rdb_bgsave_in_progress, replicas_alive cleanup, dbsize parity, debug digest) are all branch-agnostic. --------- Signed-off-by: Taeknology <[email protected]> Co-authored-by: Sarthak Aggarwal <[email protected]> Backport-Source-PR: 3772
…isconnect branch (#3772) Fixes #3686. ### Symptom `tests/integration/replication.tcl` "diskless timeout replicas drop during rdb pipe" fails on `test-macos-latest`: ``` log message of '"*Disconnecting timedout replica (full sync)*"' not found in ./tests/tmp/server.13581.2852/stdout after line: 128 till line: 151 ``` The master *did* fire a timeout disconnect, but on the streaming-sync branch instead of the full-sync one: ``` 01:58:34.346 * Streamed RDB transfer with replica 127.0.0.1:22549 succeeded (socket). 01:58:34.346 * Synchronization with replica 127.0.0.1:22549 succeeded 01:58:37.373 # Disconnecting timedout replica (streaming sync): 127.0.0.1:22548 ``` ### Root cause: same-tick cron ordering `serverCron` does two things in the same tick that compete here: 1. `checkChildrenDone` (`src/server.c:1453`) reaps the RDB child and calls `backgroundSaveDoneHandler`, which clears `server.rdb_child_type = RDB_CHILD_TYPE_NONE` at `src/rdb.c:3698`. 2. The disconnect loop at `src/replication.c:5348` runs. The `(full sync)` branch (`src/replication.c:5369-5377`) is gated on `rdb_child_type == RDB_CHILD_TYPE_SOCKET`. Once step 1 clears it, the branch is unreachable for the rest of that tick. The SIGSTOP'd replica meanwhile was already promoted via `replicaPutOnline()` (`src/replication.c:2006-2031`), so the disconnect lands in the `(streaming sync)` branch at `src/replication.c:5357-5364` instead. On Linux CI, SIGSTOP back-pressure keeps the RDB child blocked on `write()` to the parent pipe long enough that step 1 does not run in the same tick as step 2. On macOS-latest CI the child drains faster (larger loopback `SO_SNDBUF`, different scheduler quanta), so the two events collapse into one tick and the test's strict `(full sync)` wait never matches. ### Fix Accept either timeout-disconnect message, then assert exactly one such disconnect occurred so the test still rejects a regression that emits zero or multiple timeouts: ```tcl if {[catch { wait_for_log_messages -2 {"*Disconnecting timedout replica (full sync)*"} $loglines 100 100 }]} { wait_for_log_messages -2 {"*Disconnecting timedout replica (streaming sync)*"} $loglines 100 100 } assert_equal 1 [count_log_message -2 "Disconnecting timedout replica"] ``` Both branches represent a legitimate timeout-driven disconnect; the test's intent ("the slow replica is dropped because of `repl-timeout`") is preserved. The `count_log_message` assertion guards against silently widening to "any timeout anywhere". ### Prior art in this test The same `catch { wait_for_log_messages ... }` + fallback pattern is already the established convention in this very test block to absorb RDB-pipe race variance — see the post-disconnect assertions for `all_drop == "all"` and `all_drop == "slow"` at `tests/integration/replication.tcl:1011-1036`. The comment ("RDB finished before replicas were killed; accept either 1 or 2 replicas still up at pipe-read time.") describes the same kind of timing variance this PR addresses for the timeout subcase on the disconnect-emission side. ### Alternatives considered - **Synchronize `pause_process` on partial-write evidence**: rejected. Once `rdb_child_type` is cleared in the same tick, no test-side synchronization can force the `(full sync)` path to fire. - **Diagnostic logging at `src/replication.c:5360,5373`** (state + `rdb_child_type` at disconnect): deferred to a separate follow-up PR. Useful for future triage but independent review surface, and this PR is intentionally test-only. ### Verification - `grep -n "Disconnecting timedout replica" src/replication.c` confirms both emitters intact (`:5360` streaming, `:5373` full). - `grep -rn "Disconnecting timedout replica (full sync)" tests/` confirms no other test relies on the strict string. - Full local run of `integration/replication` on macOS Apple Silicon: 111 passed, 0 failed. - 10-loop run of the five `diskless * replicas drop during rdb pipe` subcases (including timeout): 50/50 pass. The race is only reproducible on CI VM conditions, so local runs validate non-regression rather than fix efficacy. - Post-disconnect assertions at `replication.tcl:988-1080` (rdb_bgsave_in_progress, replicas_alive cleanup, dbsize parity, debug digest) are all branch-agnostic. --------- Signed-off-by: Taeknology <[email protected]> Co-authored-by: Sarthak Aggarwal <[email protected]> Backport-Source-PR: 3772
…isconnect branch (#3772) Fixes #3686. ### Symptom `tests/integration/replication.tcl` "diskless timeout replicas drop during rdb pipe" fails on `test-macos-latest`: ``` log message of '"*Disconnecting timedout replica (full sync)*"' not found in ./tests/tmp/server.13581.2852/stdout after line: 128 till line: 151 ``` The master *did* fire a timeout disconnect, but on the streaming-sync branch instead of the full-sync one: ``` 01:58:34.346 * Streamed RDB transfer with replica 127.0.0.1:22549 succeeded (socket). 01:58:34.346 * Synchronization with replica 127.0.0.1:22549 succeeded 01:58:37.373 # Disconnecting timedout replica (streaming sync): 127.0.0.1:22548 ``` ### Root cause: same-tick cron ordering `serverCron` does two things in the same tick that compete here: 1. `checkChildrenDone` (`src/server.c:1453`) reaps the RDB child and calls `backgroundSaveDoneHandler`, which clears `server.rdb_child_type = RDB_CHILD_TYPE_NONE` at `src/rdb.c:3698`. 2. The disconnect loop at `src/replication.c:5348` runs. The `(full sync)` branch (`src/replication.c:5369-5377`) is gated on `rdb_child_type == RDB_CHILD_TYPE_SOCKET`. Once step 1 clears it, the branch is unreachable for the rest of that tick. The SIGSTOP'd replica meanwhile was already promoted via `replicaPutOnline()` (`src/replication.c:2006-2031`), so the disconnect lands in the `(streaming sync)` branch at `src/replication.c:5357-5364` instead. On Linux CI, SIGSTOP back-pressure keeps the RDB child blocked on `write()` to the parent pipe long enough that step 1 does not run in the same tick as step 2. On macOS-latest CI the child drains faster (larger loopback `SO_SNDBUF`, different scheduler quanta), so the two events collapse into one tick and the test's strict `(full sync)` wait never matches. ### Fix Accept either timeout-disconnect message, then assert exactly one such disconnect occurred so the test still rejects a regression that emits zero or multiple timeouts: ```tcl if {[catch { wait_for_log_messages -2 {"*Disconnecting timedout replica (full sync)*"} $loglines 100 100 }]} { wait_for_log_messages -2 {"*Disconnecting timedout replica (streaming sync)*"} $loglines 100 100 } assert_equal 1 [count_log_message -2 "Disconnecting timedout replica"] ``` Both branches represent a legitimate timeout-driven disconnect; the test's intent ("the slow replica is dropped because of `repl-timeout`") is preserved. The `count_log_message` assertion guards against silently widening to "any timeout anywhere". ### Prior art in this test The same `catch { wait_for_log_messages ... }` + fallback pattern is already the established convention in this very test block to absorb RDB-pipe race variance — see the post-disconnect assertions for `all_drop == "all"` and `all_drop == "slow"` at `tests/integration/replication.tcl:1011-1036`. The comment ("RDB finished before replicas were killed; accept either 1 or 2 replicas still up at pipe-read time.") describes the same kind of timing variance this PR addresses for the timeout subcase on the disconnect-emission side. ### Alternatives considered - **Synchronize `pause_process` on partial-write evidence**: rejected. Once `rdb_child_type` is cleared in the same tick, no test-side synchronization can force the `(full sync)` path to fire. - **Diagnostic logging at `src/replication.c:5360,5373`** (state + `rdb_child_type` at disconnect): deferred to a separate follow-up PR. Useful for future triage but independent review surface, and this PR is intentionally test-only. ### Verification - `grep -n "Disconnecting timedout replica" src/replication.c` confirms both emitters intact (`:5360` streaming, `:5373` full). - `grep -rn "Disconnecting timedout replica (full sync)" tests/` confirms no other test relies on the strict string. - Full local run of `integration/replication` on macOS Apple Silicon: 111 passed, 0 failed. - 10-loop run of the five `diskless * replicas drop during rdb pipe` subcases (including timeout): 50/50 pass. The race is only reproducible on CI VM conditions, so local runs validate non-regression rather than fix efficacy. - Post-disconnect assertions at `replication.tcl:988-1080` (rdb_bgsave_in_progress, replicas_alive cleanup, dbsize parity, debug digest) are all branch-agnostic. --------- Signed-off-by: Taeknology <[email protected]> Co-authored-by: Sarthak Aggarwal <[email protected]> Backport-Source-PR: 3772
…isconnect branch (#3772) Fixes #3686. ### Symptom `tests/integration/replication.tcl` "diskless timeout replicas drop during rdb pipe" fails on `test-macos-latest`: ``` log message of '"*Disconnecting timedout replica (full sync)*"' not found in ./tests/tmp/server.13581.2852/stdout after line: 128 till line: 151 ``` The master *did* fire a timeout disconnect, but on the streaming-sync branch instead of the full-sync one: ``` 01:58:34.346 * Streamed RDB transfer with replica 127.0.0.1:22549 succeeded (socket). 01:58:34.346 * Synchronization with replica 127.0.0.1:22549 succeeded 01:58:37.373 # Disconnecting timedout replica (streaming sync): 127.0.0.1:22548 ``` ### Root cause: same-tick cron ordering `serverCron` does two things in the same tick that compete here: 1. `checkChildrenDone` (`src/server.c:1453`) reaps the RDB child and calls `backgroundSaveDoneHandler`, which clears `server.rdb_child_type = RDB_CHILD_TYPE_NONE` at `src/rdb.c:3698`. 2. The disconnect loop at `src/replication.c:5348` runs. The `(full sync)` branch (`src/replication.c:5369-5377`) is gated on `rdb_child_type == RDB_CHILD_TYPE_SOCKET`. Once step 1 clears it, the branch is unreachable for the rest of that tick. The SIGSTOP'd replica meanwhile was already promoted via `replicaPutOnline()` (`src/replication.c:2006-2031`), so the disconnect lands in the `(streaming sync)` branch at `src/replication.c:5357-5364` instead. On Linux CI, SIGSTOP back-pressure keeps the RDB child blocked on `write()` to the parent pipe long enough that step 1 does not run in the same tick as step 2. On macOS-latest CI the child drains faster (larger loopback `SO_SNDBUF`, different scheduler quanta), so the two events collapse into one tick and the test's strict `(full sync)` wait never matches. ### Fix Accept either timeout-disconnect message, then assert exactly one such disconnect occurred so the test still rejects a regression that emits zero or multiple timeouts: ```tcl if {[catch { wait_for_log_messages -2 {"*Disconnecting timedout replica (full sync)*"} $loglines 100 100 }]} { wait_for_log_messages -2 {"*Disconnecting timedout replica (streaming sync)*"} $loglines 100 100 } assert_equal 1 [count_log_message -2 "Disconnecting timedout replica"] ``` Both branches represent a legitimate timeout-driven disconnect; the test's intent ("the slow replica is dropped because of `repl-timeout`") is preserved. The `count_log_message` assertion guards against silently widening to "any timeout anywhere". ### Prior art in this test The same `catch { wait_for_log_messages ... }` + fallback pattern is already the established convention in this very test block to absorb RDB-pipe race variance — see the post-disconnect assertions for `all_drop == "all"` and `all_drop == "slow"` at `tests/integration/replication.tcl:1011-1036`. The comment ("RDB finished before replicas were killed; accept either 1 or 2 replicas still up at pipe-read time.") describes the same kind of timing variance this PR addresses for the timeout subcase on the disconnect-emission side. ### Alternatives considered - **Synchronize `pause_process` on partial-write evidence**: rejected. Once `rdb_child_type` is cleared in the same tick, no test-side synchronization can force the `(full sync)` path to fire. - **Diagnostic logging at `src/replication.c:5360,5373`** (state + `rdb_child_type` at disconnect): deferred to a separate follow-up PR. Useful for future triage but independent review surface, and this PR is intentionally test-only. ### Verification - `grep -n "Disconnecting timedout replica" src/replication.c` confirms both emitters intact (`:5360` streaming, `:5373` full). - `grep -rn "Disconnecting timedout replica (full sync)" tests/` confirms no other test relies on the strict string. - Full local run of `integration/replication` on macOS Apple Silicon: 111 passed, 0 failed. - 10-loop run of the five `diskless * replicas drop during rdb pipe` subcases (including timeout): 50/50 pass. The race is only reproducible on CI VM conditions, so local runs validate non-regression rather than fix efficacy. - Post-disconnect assertions at `replication.tcl:988-1080` (rdb_bgsave_in_progress, replicas_alive cleanup, dbsize parity, debug digest) are all branch-agnostic. --------- Signed-off-by: Taeknology <[email protected]> Co-authored-by: Sarthak Aggarwal <[email protected]> Backport-Source-PR: 3772
…isconnect branch (#3772) Fixes #3686. ### Symptom `tests/integration/replication.tcl` "diskless timeout replicas drop during rdb pipe" fails on `test-macos-latest`: ``` log message of '"*Disconnecting timedout replica (full sync)*"' not found in ./tests/tmp/server.13581.2852/stdout after line: 128 till line: 151 ``` The master *did* fire a timeout disconnect, but on the streaming-sync branch instead of the full-sync one: ``` 01:58:34.346 * Streamed RDB transfer with replica 127.0.0.1:22549 succeeded (socket). 01:58:34.346 * Synchronization with replica 127.0.0.1:22549 succeeded 01:58:37.373 # Disconnecting timedout replica (streaming sync): 127.0.0.1:22548 ``` ### Root cause: same-tick cron ordering `serverCron` does two things in the same tick that compete here: 1. `checkChildrenDone` (`src/server.c:1453`) reaps the RDB child and calls `backgroundSaveDoneHandler`, which clears `server.rdb_child_type = RDB_CHILD_TYPE_NONE` at `src/rdb.c:3698`. 2. The disconnect loop at `src/replication.c:5348` runs. The `(full sync)` branch (`src/replication.c:5369-5377`) is gated on `rdb_child_type == RDB_CHILD_TYPE_SOCKET`. Once step 1 clears it, the branch is unreachable for the rest of that tick. The SIGSTOP'd replica meanwhile was already promoted via `replicaPutOnline()` (`src/replication.c:2006-2031`), so the disconnect lands in the `(streaming sync)` branch at `src/replication.c:5357-5364` instead. On Linux CI, SIGSTOP back-pressure keeps the RDB child blocked on `write()` to the parent pipe long enough that step 1 does not run in the same tick as step 2. On macOS-latest CI the child drains faster (larger loopback `SO_SNDBUF`, different scheduler quanta), so the two events collapse into one tick and the test's strict `(full sync)` wait never matches. ### Fix Accept either timeout-disconnect message, then assert exactly one such disconnect occurred so the test still rejects a regression that emits zero or multiple timeouts: ```tcl if {[catch { wait_for_log_messages -2 {"*Disconnecting timedout replica (full sync)*"} $loglines 100 100 }]} { wait_for_log_messages -2 {"*Disconnecting timedout replica (streaming sync)*"} $loglines 100 100 } assert_equal 1 [count_log_message -2 "Disconnecting timedout replica"] ``` Both branches represent a legitimate timeout-driven disconnect; the test's intent ("the slow replica is dropped because of `repl-timeout`") is preserved. The `count_log_message` assertion guards against silently widening to "any timeout anywhere". ### Prior art in this test The same `catch { wait_for_log_messages ... }` + fallback pattern is already the established convention in this very test block to absorb RDB-pipe race variance — see the post-disconnect assertions for `all_drop == "all"` and `all_drop == "slow"` at `tests/integration/replication.tcl:1011-1036`. The comment ("RDB finished before replicas were killed; accept either 1 or 2 replicas still up at pipe-read time.") describes the same kind of timing variance this PR addresses for the timeout subcase on the disconnect-emission side. ### Alternatives considered - **Synchronize `pause_process` on partial-write evidence**: rejected. Once `rdb_child_type` is cleared in the same tick, no test-side synchronization can force the `(full sync)` path to fire. - **Diagnostic logging at `src/replication.c:5360,5373`** (state + `rdb_child_type` at disconnect): deferred to a separate follow-up PR. Useful for future triage but independent review surface, and this PR is intentionally test-only. ### Verification - `grep -n "Disconnecting timedout replica" src/replication.c` confirms both emitters intact (`:5360` streaming, `:5373` full). - `grep -rn "Disconnecting timedout replica (full sync)" tests/` confirms no other test relies on the strict string. - Full local run of `integration/replication` on macOS Apple Silicon: 111 passed, 0 failed. - 10-loop run of the five `diskless * replicas drop during rdb pipe` subcases (including timeout): 50/50 pass. The race is only reproducible on CI VM conditions, so local runs validate non-regression rather than fix efficacy. - Post-disconnect assertions at `replication.tcl:988-1080` (rdb_bgsave_in_progress, replicas_alive cleanup, dbsize parity, debug digest) are all branch-agnostic. --------- Signed-off-by: Taeknology <[email protected]> Co-authored-by: Sarthak Aggarwal <[email protected]> Backport-Source-PR: 3772
Fixes #3686.
Symptom
tests/integration/replication.tcl"diskless timeout replicas drop during rdb pipe" fails ontest-macos-latest:The master did fire a timeout disconnect, but on the streaming-sync branch instead of the full-sync one:
Root cause: same-tick cron ordering
serverCrondoes two things in the same tick that compete here:checkChildrenDone(src/server.c:1453) reaps the RDB child and callsbackgroundSaveDoneHandler, which clearsserver.rdb_child_type = RDB_CHILD_TYPE_NONEatsrc/rdb.c:3698.src/replication.c:5348runs.The
(full sync)branch (src/replication.c:5369-5377) is gated onrdb_child_type == RDB_CHILD_TYPE_SOCKET. Once step 1 clears it, the branch is unreachable for the rest of that tick. The SIGSTOP'd replica meanwhile was already promoted viareplicaPutOnline()(src/replication.c:2006-2031), so the disconnect lands in the(streaming sync)branch atsrc/replication.c:5357-5364instead.On Linux CI, SIGSTOP back-pressure keeps the RDB child blocked on
write()to the parent pipe long enough that step 1 does not run in the same tick as step 2. On macOS-latest CI the child drains faster (larger loopbackSO_SNDBUF, different scheduler quanta), so the two events collapse into one tick and the test's strict(full sync)wait never matches.Fix
Accept either timeout-disconnect message, then assert exactly one such disconnect occurred so the test still rejects a regression that emits zero or multiple timeouts:
Both branches represent a legitimate timeout-driven disconnect; the test's intent ("the slow replica is dropped because of
repl-timeout") is preserved. Thecount_log_messageassertion guards against silently widening to "any timeout anywhere".Prior art in this test
The same
catch { wait_for_log_messages ... }+ fallback pattern is already the established convention in this very test block to absorb RDB-pipe race variance — see the post-disconnect assertions forall_drop == "all"andall_drop == "slow"attests/integration/replication.tcl:1011-1036. The comment ("RDB finished before replicas were killed; accept either 1 or 2 replicas still up at pipe-read time.") describes the same kind of timing variance this PR addresses for the timeout subcase on the disconnect-emission side.Alternatives considered
pause_processon partial-write evidence: rejected. Oncerdb_child_typeis cleared in the same tick, no test-side synchronization can force the(full sync)path to fire.src/replication.c:5360,5373(state +rdb_child_typeat disconnect): deferred to a separate follow-up PR. Useful for future triage but independent review surface, and this PR is intentionally test-only.Verification
grep -n "Disconnecting timedout replica" src/replication.cconfirms both emitters intact (:5360streaming,:5373full).grep -rn "Disconnecting timedout replica (full sync)" tests/confirms no other test relies on the strict string.integration/replicationon macOS Apple Silicon: 111 passed, 0 failed.diskless * replicas drop during rdb pipesubcases (including timeout): 50/50 pass. The race is only reproducible on CI VM conditions, so local runs validate non-regression rather than fix efficacy.replication.tcl:988-1080(rdb_bgsave_in_progress, replicas_alive cleanup, dbsize parity, debug digest) are all branch-agnostic.