alpass163 commented on code in PR #18874:
URL: https://github.com/apache/iotdb/pull/18874#discussion_r4311616330


##########
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/consensus/statemachine/schemaregion/SchemaExecutionVisitor.java:
##########
@@ -485,17 +521,20 @@ public TSStatus visitActivateTemplate(
   @Override
   public TSStatus visitBatchActivateTemplate(
       final BatchActivateTemplateNode node, final ISchemaRegion schemaRegion) {
+    final Map<Integer, Template> templateMap = new HashMap<>();
+    final Set<Integer> missingTemplateIds = new HashSet<>();
+    collectTemplates(node.getTemplateActivationMap(), templateMap, 
missingTemplateIds);
+
+    triggerAddViewColumn(node, new 
TriggerAddViewColumnVisitor.Context(templateMap));
+
     final List<TSStatus> statusList = new ArrayList<>();
     final List<PartialPath> alreadyActivatedDeviceList = new ArrayList<>();
     for (final Map.Entry<PartialPath, Pair<Integer, Integer>> entry :
         node.getTemplateActivationMap().entrySet()) {
-      final Template template =
-          
ClusterTemplateManager.getInstance().getTemplate(entry.getValue().left);
+      final Template template = templateMap.get(entry.getValue().left);
       if (Objects.isNull(template)) {
-        return new TSStatus(TSStatusCode.UNDEFINED_TEMPLATE.getStatusCode())
-            .setMessage(
-                DataNodeMiscMessages
-                    
.MESSAGE_TEMPLATE_NULL_TRYING_ACTIVATE_TEMPLATE_MAY_TEMPLATE_BEING_UNSET_1CE92779);
+        // its id is in missingTemplateIds, which is reported at the end
+        continue;

Review Comment:
   well, 



-- 
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]

Reply via email to