[server] Support limiting rebalance buckets per round#3498
Open
fhan688 wants to merge 2 commits into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR introduces an optional “round-based” rebalance execution mode in the CoordinatorServer to limit how many bucket movement tasks are activated per round, reducing pressure on large clusters while preserving legacy behavior by default (0 = disabled).
Changes:
- Added
coordinator.rebalance.max-buckets-per-roundand documented it in ops/config docs. - Implemented round-based rebalance splitting, persistence (ZooKeeper), recovery, and cancellation behavior in
RebalanceManager. - Added ZooKeeper metadata models + JSON serde (
RebalanceExecution,RebalanceRound) and corresponding unit tests.
Reviewed changes
Copilot reviewed 14 out of 14 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| website/docs/maintenance/operations/rebalance.md | Documents how to limit active bucket tasks via the new config. |
| website/docs/maintenance/configuration.md | Adds the new coordinator configuration option to the reference table. |
| fluss-server/src/test/java/org/apache/fluss/server/zk/data/RebalanceRoundJsonSerdeTest.java | Adds JSON serde tests for RebalanceRound. |
| fluss-server/src/test/java/org/apache/fluss/server/zk/data/RebalanceExecutionJsonSerdeTest.java | Adds JSON serde tests for RebalanceExecution. |
| fluss-server/src/test/java/org/apache/fluss/server/coordinator/rebalance/RebalanceManagerTest.java | Adds tests for legacy vs round-based execution, completion, recovery, cancellation, partitioned buckets. |
| fluss-server/src/main/java/org/apache/fluss/server/zk/ZooKeeperClient.java | Adds ZooKeeper APIs for rebalance execution/round metadata and recursive deletion under /cluster/rebalance. |
| fluss-server/src/main/java/org/apache/fluss/server/zk/data/ZkData.java | Defines new znodes for /cluster/rebalance/execution and /cluster/rebalance/rounds/*. |
| fluss-server/src/main/java/org/apache/fluss/server/zk/data/RebalanceRoundJsonSerde.java | Implements JSON serde for per-round persisted progress. |
| fluss-server/src/main/java/org/apache/fluss/server/zk/data/RebalanceRound.java | Adds persistent model for a rebalance round (plan + per-bucket status). |
| fluss-server/src/main/java/org/apache/fluss/server/zk/data/RebalanceExecutionJsonSerde.java | Implements JSON serde for execution-level metadata. |
| fluss-server/src/main/java/org/apache/fluss/server/zk/data/RebalanceExecution.java | Adds persistent model for round-based rebalance execution metadata. |
| fluss-server/src/main/java/org/apache/fluss/server/coordinator/rebalance/RebalanceManager.java | Core implementation: splitting, persistence, recovery, progress aggregation, and round transitions. |
| fluss-server/src/main/java/org/apache/fluss/server/coordinator/CoordinatorEventProcessor.java | Switches rebalance flow to generateAndRegisterRebalance(...) and wires config into RebalanceManager. |
| fluss-common/src/main/java/org/apache/fluss/config/ConfigOptions.java | Adds the new config option definition and description. |
Comments suppressed due to low confidence (1)
fluss-server/src/main/java/org/apache/fluss/server/coordinator/rebalance/RebalanceManager.java:226
- The log message concatenation misses a space, producing "no" + "rebalance" → "norebalance" in the emitted message. Consider using a single string literal to avoid this kind of formatting issue.
LOG.error(
"Failed to get rebalance plan from zookeeper, it will be treated as no"
+ "rebalance tasks.",
e);
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Purpose
Linked issue: #3348
Large rebalance plans may activate too many bucket movement tasks at once, which can increase pressure on the
CoordinatorServerandTabletServers in large clusters.This PR adds a coordinator configuration to limit how many bucket rebalance tasks are activated in one round. When the limit is enabled and a generated rebalance plan exceeds the limit, Fluss
splits the plan into recoverable rounds, persists full progress in ZooKeeper, and activates the next round only after all bucket tasks in the current round reach a final state.
The default behavior remains unchanged.
Brief change log
Add
coordinator.rebalance.max-buckets-per-roundwith default value0.0disables round limiting and keeps the existing behavior.Move rebalance generation and registration into
RebalanceManager.table_id,partition_id, andbucket_id.Add round-based rebalance recovery and lifecycle handling.
CoordinatorServerrestart.listRebalanceProgress.CANCELEDwhen canceling a round-based rebalance.Add ZooKeeper metadata models and JSON serde for:
RebalanceExecutionRebalanceRoundAdd tests for:
Tests
git diff --checkmvn -pl fluss-server -am -DskipITs -Dcheckstyle.skip=true -DfailIfNoTests=false -Dtest=RebalanceManagerTest,RebalanceExecutionJsonSerdeTest,RebalanceRoundJsonSerdeTest testAPI and Format
Adds a new coordinator configuration:
coordinator.rebalance.max-buckets-per-roundNo public client API or RPC protocol changes.
Adds new ZooKeeper metadata under the existing rebalance znode:
/cluster/rebalance/execution/cluster/rebalance/rounds/[roundIndex]Backward compatibility:
0preserves existing behavior.Documentation
website/docs/maintenance/configuration.md.website/docs/maintenance/operations/rebalance.md.