Skip to content

[server] Make timed-out rebalance tasks recoverable - #3860

Open
swuferhong wants to merge 3 commits into
apache:mainfrom
swuferhong:add-timeout-for-rebalance
Open

swuferhong wants to merge 3 commits into
apache:mainfrom
swuferhong:add-timeout-for-rebalance

Conversation

@swuferhong

Copy link
Copy Markdown
Contributor

Purpose

Linked issue: close #3859

Treat rebalance timeout as a non-final state and continue tracking timed-out bucket migrations without blocking subsequent tasks.

Fence stale timeout and NotifyLeaderAndIsr events by rebalance attempt and request epochs. Reconcile migrations idempotently from persisted assignment and LeaderAndIsr state, and recover unfinished tasks after coordinator restart.

Persist cancellation intent before changing local state, drain admitted tasks safely, retry final-state persistence, and treat deleted buckets as completed.

Brief change log

Tests

API and Format

Documentation

@swuferhong
swuferhong force-pushed the add-timeout-for-rebalance branch 3 times, most recently from a152704 to 299a769 Compare August 25, 2026 09:18

@platinumhamburg platinumhamburg 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.

LGTM +1.

I have left three non-blocking suggestions concerning operational configurability and regression coverage.

@swuferhong
swuferhong force-pushed the add-timeout-for-rebalance branch from 299a769 to 9efad45 Compare September 14, 2026 08:56
@swuferhong
swuferhong force-pushed the add-timeout-for-rebalance branch 2 times, most recently from d7dc9b3 to eb5da01 Compare October 9, 2026 12:44
@swuferhong
swuferhong force-pushed the add-timeout-for-rebalance branch from eb5da01 to e8fb787 Compare October 19, 2026 05:40

@fxbing fxbing 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.

Thanks for your contribution! I've run into this issue as well and left a few comments for you to take a look at.

return;
}

for (Map.Entry<TableBucket, RebalancePlanForBucket> entry :

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.

Could rebuilding all plans as pending leave existing migrations outside the admission limit during recovery?

A local Manager/serde probe reproduced this with maxTrackedTimedOutTasks=1:

  1. Start bucket A, leave its assignment at the union state, and move it to TIMEOUT. Further admission is correctly blocked.
  2. Serialize and reload the persisted task, then recover a new manager while preserving A's union assignment.
  3. Exercise a recovery order where a previously unstarted bucket B appears before A.

B is then admitted while A remains pending. Both buckets have union assignments, but A's execution key and rebalance-plan lookup return null.

The probe used 12 colliding TableBucket keys—new TableBucket(i + 1L, 31 * (11 - i)), for i=0..11—to exercise a different iteration order after deserialization. It used the real Manager/serde/context with a fake executor, so this demonstrates the admission and tracking behavior rather than actual TabletServer traffic.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Agreed. Recovery now classifies every persisted bucket before admitting any new work. Buckets that are no longer at origin are restored directly as tracked TIMEOUT attempts with an execution key and an immediate reconciliation event. Only after all buckets have been classified does normal admission run, so an intermediate migration is discovered before the maxTrackedTimedOutTasks check can admit another origin task.

swuferhong and others added 2 commits October 26, 2026 19:03
Keep timed-out bucket migrations under bounded reconciliation while admitting
new work. Persist cancellation intent and final status, recover intermediate
assignments, and require a current leader acknowledgement before completion.
Fence stale responses and avoid repeated elections for applied leader moves.

Expose recovery limits and replan failed migrations using the configured
replica count. Document the state transitions and recovery settings, share
test setup, and retain targeted failure and restart coverage. Exempt only
ConfigOptions from the Checkstyle file length limit.

Skip startup recovery on ZooKeeper read failure to allow new rebalance
requests, and leave a TODO for recovery retries.

Validation: 89 targeted and integration tests passed, including five rebalance
integration cases. After the startup recovery adjustment, reran all 35
RebalanceManagerTest cases successfully. Checkstyle and Spotless checks passed.

Co-Authored-By: Codex <noreply@openai.com>
AI-Model: gpt-6
AI-Contributed/Feature: 7/7
AI-Contributed/UT: 0/0
Co-Authored-By: Codex <noreply@openai.com>
AI-Model: gpt-5.6-sol
AI-Contributed/Feature: 58/58
AI-Contributed/UT: 208/208
@swuferhong
swuferhong force-pushed the add-timeout-for-rebalance branch from e8fb787 to ea7ff36 Compare October 26, 2026 11:59
Co-Authored-By: Codex <noreply@openai.com>
Co-Authored-By: Qoder <noreply@qoder.com>
AI-Model: gpt-6
AI-Contributed/Feature: 149/149
AI-Contributed/UT: 29/29

Co-Authored-By: Codex <noreply@openai.com>
AI-Model: gpt-5.6-sol
AI-Contributed/Feature: 60/60
AI-Contributed/UT: 84/84
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.

[Improvement] Make timed-out rebalance tasks recoverable

4 participants