cmccabe commented on code in PR #15702:
URL: https://github.com/apache/kafka/pull/15702#discussion_r1614156696


##########
metadata/src/main/java/org/apache/kafka/controller/ConfigurationControlManager.java:
##########
@@ -308,6 +330,48 @@ private ApiError validateAlterConfig(ConfigResource 
configResource,
         return ApiError.NONE;
     }
 
+    void maybeTriggerPartitionUpdateOnMinIsrChange(List<ApiMessageAndVersion> 
records) {
+        List<ConfigRecord> minIsrRecords = new ArrayList<>();
+        Map<String, String> topicMap = new HashMap<>();
+        Map<String, String> configRemovedTopicMap = new HashMap<>();
+        records.forEach(record -> {
+            if (MetadataRecordType.fromId(record.message().apiKey()) == 
MetadataRecordType.CONFIG_RECORD) {
+                ConfigRecord configRecord = (ConfigRecord) record.message();
+                if 
(configRecord.name().equals(TopicConfig.MIN_IN_SYNC_REPLICAS_CONFIG)) {
+                    minIsrRecords.add(configRecord);
+                    if (Type.forId(configRecord.resourceType()) == Type.TOPIC) 
{
+                        if (configRecord.value() == null) 
topicMap.put(configRecord.resourceName(), configRecord.value());
+                        else 
configRemovedTopicMap.put(configRecord.resourceName(), configRecord.value());
+                    }
+                }
+            }
+        });
+
+        if (minIsrRecords.isEmpty()) return;
+        if (topicMap.size() == minIsrRecords.size()) {
+            // If all the min isr config updates are on the topic level, we 
can trigger a simpler update just on the
+            // updated topics.
+            
records.addAll(minIsrConfigUpdatePartitionHandler.addRecordsForMinIsrUpdate(
+                new ArrayList<>(topicMap.keySet()),
+                topicName -> topicMap.get(topicName))
+            );
+            return;
+        }
+
+        // Because it may require multiple layer look up for the min ISR 
config value. Build a config data copy and apply
+        // the config updates to it. Use this config copy for the min ISR look 
up.
+        Map<ConfigResource, TimelineHashMap<String, String>> pendingConfigData 
= new HashMap<>();
+        SnapshotRegistry localSnapshotRegistry = new SnapshotRegistry(new 
LogContext("dummy-config-update"));

Review Comment:
   Maybe I'm missing something, but I don't think this works... 
`pendingConfigData` will have some of the new changes you made, but not all of 
the existing changes. So, for example, perhaps we are changing the cluster 
config for min topic ISR, but the node config for the current controller node 
is unchanged. It should take priority, but it won't be in 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: jira-unsubscr...@kafka.apache.org

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

Reply via email to