Skip to content

Add comment and test for bio RDB disk transfer receive timeout - #4277

Merged
enjoy-binbin merged 3 commits into
valkey-io:unstablefrom
enjoy-binbin:minor_cleanup
Jul 29, 2026
Merged

Add comment and test for bio RDB disk transfer receive timeout#4277
enjoy-binbin merged 3 commits into
valkey-io:unstablefrom
enjoy-binbin:minor_cleanup

Conversation

@enjoy-binbin

@enjoy-binbin enjoy-binbin commented Jul 28, 2026

Copy link
Copy Markdown
Member

The disk-saving bio thread bounds its blocking RDB read with
repl_syncio_timeout, and the abort flag is only checked between
reads, so a silent primary can stall the main thread in
cancelReplicationHandshake() for up to that timeout.

No behavior change: just document why repl_syncio_timeout is
used here instead of repl-timeout, and add a test covering the
abort path.

The `replicaReceiveRDBFromPrimaryToDisk`, introduced in valkey-io#1784,
incorrectly uses `repl_syncio_timeout` (default 5s) for the socket
receive timeout during RDB bulk transfer. This timeout is intended
for short synchronous I/O operations during the handshake phase.

Signed-off-by: Binbin <binloveplay1314@qq.com>
@coderabbitai

coderabbitai Bot commented Jul 28, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 866347f1-5c92-4de7-9c22-bde570cd0e10

📥 Commits

Reviewing files that changed from the base of the PR and between 90b5fd8 and fc6aaa6.

📒 Files selected for processing (1)
  • tests/integration/replication.tcl

📝 Walkthrough

Walkthrough

Replication handshake cancellation now documents that a Bio thread blocked in an RDB socket read can delay the main thread up to repl_syncio_timeout. An integration test exercises this behavior during diskless replication.

Changes

Replication handshake cancellation

Layer / File(s) Summary
Document and test cancellation timeout
src/replication.c, tests/integration/replication.tcl
Comments describe timeout behavior in the RDB receive and handshake-cancellation paths. A diskless replication test verifies cancellation while streamed RDB reading is blocked and restores the configured delay afterward.

Estimated code review effort: 2 (Simple) | ~10 minutes

Suggested reviewers: murphyjacob4

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly matches the main change: documenting the RDB receive timeout and adding a test.
Description check ✅ Passed The description directly explains the timeout rationale and the added abort-path test.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@enjoy-binbin enjoy-binbin moved this to To be backported in Valkey 9.0 Jul 28, 2026
@enjoy-binbin enjoy-binbin moved this to To be backported in Valkey 9.1 Jul 28, 2026

@valkey-review-bot valkey-review-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One concern with the new value: in the bio thread this socket timeout also doubles as the interval at which server.replica_bio_abort_save is observed, and cancelReplicationHandshake() busy-waits on the main thread for that. Details inline.

Comment thread src/replication.c Outdated
@codecov

codecov Bot commented Jul 28, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 76.79%. Comparing base (4733aed) to head (fc6aaa6).
⚠️ Report is 1 commits behind head on unstable.

Additional details and impacted files
@@             Coverage Diff              @@
##           unstable    #4277      +/-   ##
============================================
- Coverage     76.84%   76.79%   -0.05%     
============================================
  Files           162      162              
  Lines         81479    81479              
============================================
- Hits          62610    62571      -39     
- Misses        18869    18908      +39     
Files with missing lines Coverage Δ
src/replication.c 85.78% <ø> (-0.37%) ⬇️

... and 19 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@enjoy-binbin
enjoy-binbin marked this pull request as draft July 28, 2026 03:51
Signed-off-by: Binbin <binloveplay1314@qq.com>
@enjoy-binbin enjoy-binbin changed the title Use repl_timeout for RDB disk transfer receive timeout Add comment and test for RDB disk transfer receive timeout Jul 28, 2026
@enjoy-binbin enjoy-binbin changed the title Add comment and test for RDB disk transfer receive timeout Add comment and test for bio RDB disk transfer receive timeout Jul 28, 2026
@enjoy-binbin
enjoy-binbin marked this pull request as ready for review July 28, 2026 06:59
@enjoy-binbin enjoy-binbin added the text comments, docs and typos label Jul 28, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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`:
- Around line 1708-1712: Update the cancellation test around the $replica
replicaof no one call to measure its elapsed duration and assert it stays below
a tolerant upper bound that is shorter than the normal repl-timeout, while
retaining the existing slow-command log assertion.
🪄 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: a250b14c-d16e-4591-b905-9bf95bb15dec

📥 Commits

Reviewing files that changed from the base of the PR and between 70712a9 and 90b5fd8.

📒 Files selected for processing (2)
  • src/replication.c
  • tests/integration/replication.tcl

Comment thread tests/integration/replication.tcl Outdated
Signed-off-by: Binbin <binloveplay1314@qq.com>
@enjoy-binbin
enjoy-binbin merged commit 74249be into valkey-io:unstable Jul 29, 2026
64 checks passed
@enjoy-binbin
enjoy-binbin deleted the minor_cleanup branch July 29, 2026 02:22
alon-arenberg pushed a commit to alon-arenberg/valkey that referenced this pull request Jul 30, 2026
…y-io#4277)

The disk-saving bio thread bounds its blocking RDB read with
repl_syncio_timeout, and the abort flag is only checked between
reads, so a silent primary can stall the main thread in
cancelReplicationHandshake() for up to that timeout.

No behavior change: just document why repl_syncio_timeout is
used here instead of repl-timeout, and add a test covering the
abort path.

Signed-off-by: Binbin <binloveplay1314@qq.com>
Signed-off-by: Alon Arenberg <alonare@amazon.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

text comments, docs and typos

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants