CalvinConfluent commented on code in PR #14312:
URL: https://github.com/apache/kafka/pull/14312#discussion_r1349612624
##########
metadata/src/main/java/org/apache/kafka/controller/PartitionChangeBuilder.java:
##########
@@ -328,13 +349,38 @@ public Optional<ApiMessageAndVersion> build() {
completeReassignmentIfNeeded();
+ boolean isElrEnabled = metadataVersion.isElrSupported();
+ if (isElrEnabled) {
+ populateTargetElr();
+ }
+
tryElection(record);
triggerLeaderEpochBumpIfNeeded(record);
- if (record.isr() == null && !targetIsr.isEmpty() &&
!targetIsr.equals(Replicas.toList(partition.isr))) {
- // Set the new ISR if it is different from the current ISR and
unclean leader election didn't already set it.
- record.setIsr(targetIsr);
+ boolean isCleanLeaderElection = record.isr() == null;
+
+ // Clean the ELR related fields if it is an unclean election or ELR is
disabled.
+ if (!isCleanLeaderElection || !isElrEnabled) {
+ targetElr = Collections.emptyList();
+ targetLastKnownElr = Collections.emptyList();
+ }
+
+ if (!targetElr.equals(Replicas.toList(partition.elr))) {
+ record.setEligibleLeaderReplicas(targetElr);
+ }
+ if
(!targetLastKnownElr.equals(Replicas.toList(partition.lastKnownElr))) {
+ record.setLastKnownELR(targetLastKnownElr);
+ }
+
+ // The record.isr is null if it is a clean election. In this case, it
will
+ // 1. Set the new ISR if it is different from the current ISR.
+ // 2. Set the new ELR/LastKnowElr if it is different from the current
ones.
+ if (isCleanLeaderElection) {
+ // TODO(KIP-966) If ELR is enabled, the ISR is allowed to be empty.
Review Comment:
The leader election part (including allowing empty ISR) will be a separate
PR. Removed the TODO.
--
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]