Skip to content

[server] Store rebalance tasks in remote storage - #5133

Open
swuferhong wants to merge 1 commit into
apache:mainfrom
swuferhong:refactor-rebalance-plan-storage
Open

swuferhong wants to merge 1 commit into
apache:mainfrom
swuferhong:refactor-rebalance-plan-storage

Conversation

@swuferhong

Copy link
Copy Markdown
Contributor

Purpose

Linked issue: close #3868

A rebalance task contains the complete bucket migration plan. As clusters grow, the serialized task can approach ZooKeeper's znode size limit, which may cause persistence or coordinator recovery to fail.

Loading a large rebalance task synchronously during coordinator initialization would also make coordinator startup depend on remote storage latency and availability.

This PR stores large rebalance tasks in remote storage while keeping ZooKeeper as the authoritative pointer. It also moves rebalance recovery out of the synchronous coordinator startup path.

Brief change log

Tests

API and Format

Documentation

@swuferhong
swuferhong force-pushed the refactor-rebalance-plan-storage branch 5 times, most recently from 2d862fd to e2f1b36 Compare November 11, 2026 08:08
@swuferhong
swuferhong force-pushed the refactor-rebalance-plan-storage branch 2 times, most recently from f6fd7f0 to 4af1bb2 Compare November 24, 2026 01:44
@swuferhong
swuferhong force-pushed the refactor-rebalance-plan-storage branch from 4af1bb2 to 0bfc8f5 Compare November 27, 2026 07:51
@wuchong

wuchong commented Nov 27, 2026

Copy link
Copy Markdown
Member

Could we narrow this PR to the original problem: a large bucket migration plan can exceed ZooKeeper’s znode size limit? The current implementation also changes how the coordinator handles cancellation, finalization, progress queries, and concurrent submissions. With AI-assisted changes in particular, I think we should be deliberate about how much complexity a focused fix introduces.

I’d suggest a smaller design:

  1. Write the immutable bucket migration plan to remote storage once. Keep the plan reference, checksum, overall status, and cancellation intent in ZooKeeper. Canceling or completing a rebalance can then update the control state while reusing the same plan file.
  2. Keep the initial upload and startup recovery synchronous for now. A slow upload can delay other coordinator events, but it happens once per rebalance. I’d start with the existing execution model and revisit async I/O separately if we observe a material delay. That keeps the existing behavior for progress queries and duplicate requests, without introducing persistenceInProgress branches or a new completion event.
  3. Keep the change behind RebalanceTaskStore. Could we replace the existing zkClient.getRebalanceTask() and zkClient.registerRebalanceTask(...) calls with store.load() and store.persist(...), and let the store own the storage format, legacy reads, and file lifecycle? That should leave the rebalance state machine largely unchanged.

The test I’d most like to see is a plan that actually exceeds the znode limit: submit it, recover it after a coordinator restart, and verify that cancellation and finalization reuse the original remote file.


private final String id;
private final List<Endpoint> endpoints;
private final Set<String> supportedFeatures;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Could we drop supportedFeatures from CoordinatorAddress? For this change, we could keep existing inline rebalance tasks in their original format and let the platform reject new rebalances until the rolling upgrade is complete. Checking only live coordinators can miss an older standby that is temporarily offline and later takes over with a remote handle it cannot read.

My concern is that this list becomes a long-lived part of the ZooKeeper registration format. If each incompatible znode format change needs its own flag, every coordinator registration grows, and we add another capability check to maintain.

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.

[server] Store large rebalance plans outside ZooKeeper

2 participants