CalvinConfluent commented on code in PR #14593:
URL: https://github.com/apache/kafka/pull/14593#discussion_r1369023859


##########
metadata/src/main/java/org/apache/kafka/controller/PartitionChangeBuilder.java:
##########
@@ -253,17 +269,30 @@ private ElectionResult electAnyLeader() {
         return new ElectionResult(NO_LEADER, false);
     }
 
+    private boolean canElectLastKnownLeader() {
+        return eligibleLeaderReplicasEnabled && lastKnownLeaderEnabled && 
targetElr.isEmpty() && targetIsr.isEmpty()
+            && partition.lastKnownElr.length == 1 && 
isAcceptableLeader.test(partition.lastKnownElr[0]);

Review Comment:
   We can use LKL if
   - ELR is enabled
   - LKL is enabled (which means the log inspection unclean recovery is not 
ready)
   - ISR and ELR are going to be empty. Choosing LKL is an unclean leader 
election, it maintains the current non-empty ISR behavior(an equivalent way to 
elect LKL if no other choice).
   - Previous LKE has a single member. Meaning the LKL has been stored in the 
LKE field. Though it is not completely correct if unclean recovery is turned on 
and off, we don't have a better choice in this case.
   - This candidate is unfenced.
   
   If log inspection unclean recovery is not enabled, The LKE can only have 0 
or 1 member.



-- 
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: jira-unsubscr...@kafka.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to