showuon commented on code in PR #16866:
URL: https://github.com/apache/kafka/pull/16866#discussion_r1733923334
##########
metadata/src/main/java/org/apache/kafka/controller/QuorumController.java:
##########
@@ -1383,6 +1394,54 @@ private void cancelMaybeBalancePartitionLeaders() {
queue.cancelDeferred(MAYBE_BALANCE_PARTITION_LEADERS);
}
+ private static final String MAYBE_ELECT_UNCLEAN_LEADERS =
"maybeElectUncleanLeaders";
+
+ private void maybeScheduleNextElectUncleanLeaders() {
+ if (uncleanScheduled != ImbalanceSchedule.SCHEDULED &&
+ replicationControl.areSomePartitionsLeaderless()) {
+ log.debug(
+ "Scheduling write event for {} because scheduled ({}), and
areSomePartitionsLeaderless ({})",
+ MAYBE_ELECT_UNCLEAN_LEADERS,
+ uncleanScheduled,
+ replicationControl.areSomePartitionsLeaderless()
+ );
+
+ ControllerWriteEvent<Boolean> event = new
ControllerWriteEvent<>(MAYBE_ELECT_UNCLEAN_LEADERS, () -> {
+ long startTimeNs = time.nanoseconds();
+ ControllerResult<Boolean> result =
replicationControl.maybeBalancePartitionLeaders();
Review Comment:
I was testing it and wondered why it didn't work as expected. Turns out we
invoke `maybeBalancePartitionLeaders` here, which should be
`maybeElectUncleanLeaders`... :)
--
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]