Copilot commented on code in PR #3556:
URL: https://github.com/apache/fluss/pull/3556#discussion_r3533529287


##########
fluss-server/src/main/java/org/apache/fluss/server/coordinator/CoordinatorEventProcessor.java:
##########
@@ -1502,21 +1505,17 @@ private void tryToCompleteRebalanceTask(TableBucket 
tableBucket) {
                 if (planForBucket.isLeaderChanged() && 
!reassignment.isBeingReassigned()) {
                     LeaderAndIsr leaderAndIsr = 
zooKeeperClient.getLeaderAndIsr(tableBucket).get();
                     int currentLeader = leaderAndIsr.leader();
-                    if (currentLeader == planForBucket.getNewLeader()) {
+                    if (canCompleteLeaderOnlyRebalanceTask(
+                            notifyLeaderAndIsrResultForBucket,
+                            responseServerId,
+                            planForBucket,
+                            currentLeader)) {
                         // leader action finish.
                         rebalanceManager.finishRebalanceTask(
                                 tableBucket, RebalanceStatus.COMPLETED);
                     }

Review Comment:
   In the leader-only rebalance completion path, the code always performs a 
ZooKeeper getLeaderAndIsr() call, even when the NotifyLeaderAndIsr response is 
failed or comes from a replica that is not the target new leader. Since you now 
have `succeeded()` and `responseServerId`, you can short-circuit those cases to 
avoid unnecessary ZooKeeper reads.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to