Skip to content

Deflake slot migration waits by using the suite's 50s bound - #4490

Open
KewangZhili wants to merge 1 commit into
valkey-io:unstablefrom
KewangZhili:deflake-migrateslots-helper-timeouts
Open

Deflake slot migration waits by using the suite's 50s bound#4490
KewangZhili wants to merge 1 commit into
valkey-io:unstablefrom
KewangZhili:deflake-migrateslots-helper-timeouts

Conversation

@KewangZhili

Copy link
Copy Markdown

Fixes #4326 and #4311. Both are the same root cause in tests/unit/cluster/cluster-migrateslots.tcl.

What failed

Issue Helper Reported state at timeout
#4326 wait_for_migration source node still owned slot 16383 — ownership had not transferred yet
#4311 wait_for_migration_field state was reading-establish-response, an intermediate state

Both on test-ubuntu-tls-io-threads, the slowest CI configuration. Neither shows a wrong result — both show an operation still in flight.

Root cause

  • Three helpers wait on work that completes asynchronously across the cluster, but allow only 10s.
  • The rest of the cluster suite allows 50s for cluster-wide conditions (wait_for_condition 1000 50).
  • This same file already uses 50s for 7 of its other waits, so these three were the outliers.
flowchart LR
    S["MIGRATESLOTS issued"] --> P["migration in progress<br/>(reading-establish-response,<br/>ownership not yet moved)"]
    P -->|"10s bound expires here<br/>→ test FAILS"| F["reported as failure"]
    P -->|"work actually completes"| D["done, correct result"]
    style F fill:#ffe0e0
    style D fill:#e0ffe0
Loading

Fix

  1. wait_for_migration — 10s → 50s
  2. wait_for_migration_field — 10s → 50s
  3. wait_for_countkeysinslot — 10s → 50s
  4. Corrected the within 10000 ms text in those three failure messages, which would otherwise report the wrong bound.

Left at 10s deliberately:

  • the two cluster-slot-migration-log-max-len waits — observe a local config effect
  • the server-restart wait — observes a local restart, not cluster propagation

Evidence

Bound only applies when a wait is about to fail, so there is no cost on the passing path:

Runs Result Wall time
Before 3 137 passed, 0 failed ~127s avg
After 3 137 passed, 0 failed 126.3s, 127.0s, 119.8s

Not included

Both have occurrences:1 and I could not reproduce either, so I left them alone rather than guess.

wait_for_migration, wait_for_migration_field and wait_for_countkeysinslot wait
on work that completes asynchronously across the cluster, but each allowed only
10s. The rest of the cluster suite allows 50s for cluster-wide conditions, and
this same file already uses 50s for its other waits, so these three were the
outliers.

Both reported failures show the operation in progress rather than wrong, having
simply not finished inside 10s on the slowest CI configuration:

  valkey-io#4326  wait_for_migration: the source still owned slot 16383, so ownership had
         not transferred yet.
  valkey-io#4311  wait_for_migration_field: state was reading-establish-response, an
         intermediate state on the way to the expected one.

Raise the three helpers to the 50s the suite already uses. The bound only takes
effect when a wait is about to fail, so this costs nothing on the passing path:
three runs before the change averaged 127s and three after averaged 124s, with
137 tests passing every time.

The two waits on cluster-slot-migration-log-max-len and the one on a server
restart keep their 10s, since those observe local effects rather than
cluster-wide propagation.

Signed-off-by: Himangshu Deka <hdeka@salesforce.com>
@coderabbitai

coderabbitai Bot commented Aug 20, 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: 469172de-7b4d-4965-ae50-578689040104

📥 Commits

Reviewing files that changed from the base of the PR and between 3f0d910 and c255711.

📒 Files selected for processing (1)
  • tests/unit/cluster/cluster-migrateslots.tcl

Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.


📝 Walkthrough

Walkthrough

The migration test wait helpers now use 50-second timeouts for migration state, key-count, and slot-ownership conditions. Comments describe the asynchronous operations covered by these waits, and timeout messages report the new bound.

Changes

Cluster migration test waits

Layer / File(s) Summary
Migration wait timeout updates
tests/unit/cluster/cluster-migrateslots.tcl
The wait_for_migration_field, wait_for_countkeysinslot, and wait_for_migration helpers now wait up to 50 seconds. Comments document asynchronous cluster-wide operations, and failure messages use the updated timeout.

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

Merge Risk: ⚪ Minimal · up to c2557

This localized test-only change aligns three asynchronous migration waits with the suite's existing 50-second bound and corrects their timeout messages; no actionable merge-blocking risk remains after normal checks and review.

Possibly related issues

Possibly related PRs

Suggested reviewers: enjoy-binbin, sarthakaggarwal97

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the primary change: increasing slot migration wait bounds to 50 seconds.
Description check ✅ Passed The description directly explains the affected helpers, root cause, fix, evidence, and linked intermittent test failures.
Linked Issues check ✅ Passed The changes address issue #4326 by extending the slot migration wait and correcting its timeout message.
Out of Scope Changes check ✅ Passed All changes are limited to related slot migration test waits and their failure messages.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[TEST-FAILURE] Slot migration DBSIZE after migration in tests/unit/cluster/cluster-migrateslots.tcl

1 participant