Skip to content

[rebalance] Support preferred leader election goal - #4236

Open
sakshichitnis27 wants to merge 1 commit into
apache:mainfrom
sakshichitnis27:codex/4086-preferred-leader-election
Open

[rebalance] Support preferred leader election goal#4236
sakshichitnis27 wants to merge 1 commit into
apache:mainfrom
sakshichitnis27:codex/4086-preferred-leader-election

Conversation

@sakshichitnis27

@sakshichitnis27 sakshichitnis27 commented Sep 6, 2026

Copy link
Copy Markdown

Purpose

Linked issue: close #4086

Add a deterministic, manually triggered preferred leader election operation that restores bucket leadership to the first replica in each persisted assignment without moving replicas.

Brief change log

  • Add the standalone PREFERRED_LEADER_ELECTION goal to the Java and Rust Admin APIs.
  • Generate leader-only plans only when assignment[0] is alive, online, in the ISR, and not offline-tagged.
  • Preserve replica assignments and reject combinations with other rebalance goals.
  • Revalidate the target before execution and prevent fallback to another replica.
  • Expose the goal through the existing Flink SQL rebalance procedure.
  • Add focused unit and integration coverage for recovery, unavailable and offline-tagged replicas, assignment preservation, idempotency, and mixed-goal rejection.

Tests

Passed:

  • ./mvnw -pl fluss-common -Dtest=GoalTypeTest test
  • ./mvnw -q -pl fluss-server -am -Dtest=PreferredLeaderElectionGoalTest,GoalOptimizerTest,GoalOptimizerUtilsTest,LeaderReplicaDistributionGoalTest,ReplicaLeaderElectionTest -Dsurefire.failIfNoSpecifiedTests=false test
  • ./mvnw -q -pl fluss-client -am -Dtest=RebalanceITCase#testPreferredLeaderElectionAfterRecovery -Dsurefire.failIfNoSpecifiedTests=false test
  • ./mvnw -q -pl fluss-flink/fluss-flink-1.20 -am -Dtest=Flink120ProcedureITCase#testPreferredLeaderElectionProcedure -Dsurefire.failIfNoSpecifiedTests=false test
  • ./mvnw -q -pl fluss-common,fluss-server,fluss-client,fluss-flink/fluss-flink-common -am -DskipTests validate

The full fluss-server suite ran 1,323 tests on the Oracle host. Seven unrelated storage tests failed because the host filesystem was above the tests' 85% disk-usage safety threshold and contained non-fresh test storage; no rebalance or leader-election tests failed.

Rust tests were not run locally because the Oracle host does not have cargo or rustc.

API and Format

Adds GoalType.PREFERRED_LEADER_ELECTION with wire value 3. No RPC schema or storage-format changes.

Documentation

Documents Java Admin and Flink SQL usage, standalone-goal behavior, and preferred-replica eligibility requirements.

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.

[rebalance] Support preferred leader election goal

1 participant