Skip to content

[server] Require new leader ack for leader-only rebalance#3556

Merged
wuchong merged 2 commits into
apache:mainfrom
swuferhong:leader-only-rebalance-hotfix
Jul 9, 2026
Merged

[server] Require new leader ack for leader-only rebalance#3556
wuchong merged 2 commits into
apache:mainfrom
swuferhong:leader-only-rebalance-hotfix

Conversation

@swuferhong

Copy link
Copy Markdown
Contributor

Purpose

Linked issue: close #3555

Leader-only rebalance previously completed once the current leader matched
the target leader after any NotifyLeaderAndIsr response for the bucket. Since
NotifyLeaderAndIsr is sent to multiple replicas, this could complete the task
before the new leader acknowledged the request.

Pass the bucket result and response server id into the completion check, and
only complete leader-only rebalance when the result succeeded and the response
came from the target new leader. Keep LeaderAndIsr change handling from
directly completing leader-only rebalance tasks.

Brief change log

Tests

API and Format

Documentation

Copilot AI 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.

Pull request overview

This PR fixes the completion criteria for leader-only rebalance in the coordinator so that a rebalance task is only marked complete after the target new leader has successfully acknowledged NotifyLeaderAndIsr, preventing premature completion when other replicas respond first (Issue #3555).

Changes:

  • Pass NotifyLeaderAndIsr per-bucket result + responseServerId into rebalance completion checks.
  • Require leader-only rebalance completion to be gated by: result.succeeded(), response from newLeader, and currentLeader == newLeader.
  • Add/extend coordinator tests to verify leader-only rebalance waits for the new leader’s successful response.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
fluss-server/src/main/java/org/apache/fluss/server/coordinator/CoordinatorEventProcessor.java Tightens leader-only rebalance completion conditions using the responding server id and per-bucket success, and avoids completing leader-only rebalance from leader/isr-change events.
fluss-server/src/test/java/org/apache/fluss/server/coordinator/CoordinatorEventProcessorTest.java Adds targeted tests to ensure leader-only rebalance doesn’t complete on successful responses from non-target replicas and validates the new completion predicate.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@swuferhong swuferhong force-pushed the leader-only-rebalance-hotfix branch from 1c56948 to 186959a Compare July 7, 2026 11:32
@swuferhong

Copy link
Copy Markdown
Contributor Author

@wuchong copilot's comments addressed. PTAL, thanks.

@wuchong wuchong merged commit e1b0907 into apache:main Jul 9, 2026
17 checks passed
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] Leader-only rebalance may finish before new leader acknowledges NotifyLeaderAndIsr

3 participants