artemlivshits commented on code in PR #14706:
URL: https://github.com/apache/kafka/pull/14706#discussion_r1399798771
##########
metadata/src/main/java/org/apache/kafka/controller/PartitionChangeBuilder.java:
##########
@@ -466,6 +466,10 @@ private void
maybeUpdateLastKnownLeader(PartitionChangeRecord record) {
partition.lastKnownElr[0] != partition.leader)) {
// Only update the last known leader when the first time the
partition becomes leaderless.
record.setLastKnownELR(Arrays.asList(partition.leader));
+ } else if ((recordHasLeader(record) || partition.leader != NO_LEADER)
Review Comment:
Can we have a case when `record.leader() == NO_LEADER && partition.leader
!= NO_LEADER` (i.e. partion has a valid leader but will not have a valid
leader)?
Would a more proper condition be `(recordHasLeader(record) ||
(partition.leader != NO_LEADER && record.leader() == NO_LEADER_CHANGE))`
##########
metadata/src/main/java/org/apache/kafka/controller/ReplicationControlManager.java:
##########
@@ -1772,7 +1814,8 @@ void generateLeaderAndIsrUpdates(String context,
// where there is an unclean leader election which chooses a leader
from outside
// the ISR.
IntPredicate isAcceptableLeader =
- r -> (r != brokerToRemove) && (r == brokerToAdd ||
clusterControl.isActive(r));
+ r -> (r != brokerToRemove && r != brokerWithUncleanShutdown)
Review Comment:
Can we update the comments to reflect the new logic?
##########
metadata/src/main/java/org/apache/kafka/controller/BrokersToElrs.java:
##########
@@ -0,0 +1,161 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.kafka.controller;
Review Comment:
It looks like that in order to work correctly, we need to make sure that ISR
and ELR are always disjoint sets (otherwise we'd generate multiple records for
the same partition). Can we add a comment about this?
##########
metadata/src/main/java/org/apache/kafka/controller/BrokersToElrs.java:
##########
@@ -0,0 +1,161 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.kafka.controller;
+
+import org.apache.kafka.common.Uuid;
+import org.apache.kafka.metadata.Replicas;
+import org.apache.kafka.timeline.SnapshotRegistry;
+import org.apache.kafka.timeline.TimelineHashMap;
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Map;
+
+import static org.apache.kafka.metadata.Replicas.NONE;
+
+public class BrokersToElrs {
+ private final SnapshotRegistry snapshotRegistry;
+
+ private final TimelineHashMap<Integer, TimelineHashMap<Uuid, int[]>>
elrMembers;
Review Comment:
Can we add a comment what's mapped to what here?
--
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]