This is an automated email from the ASF dual-hosted git repository.

rong pushed a commit to branch dev/1.3
in repository https://gitbox.apache.org/repos/asf/iotdb.git


The following commit(s) were added to refs/heads/dev/1.3 by this push:
     new c9d7fe9bcbc Reduced the error log cause by batch activate template 
when some devices are already activated (#14661) (#14665)
c9d7fe9bcbc is described below

commit c9d7fe9bcbc4e055c56459ee6a423ed8d7a5c706
Author: Caideyipi <[email protected]>
AuthorDate: Thu Jan 9 19:10:27 2025 +0800

    Reduced the error log cause by batch activate template when some devices 
are already activated (#14661) (#14665)
---
 .../statemachine/schemaregion/SchemaExecutionVisitor.java | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/consensus/statemachine/schemaregion/SchemaExecutionVisitor.java
 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/consensus/statemachine/schemaregion/SchemaExecutionVisitor.java
index 293f91ef57d..a036d6cb004 100644
--- 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/consensus/statemachine/schemaregion/SchemaExecutionVisitor.java
+++ 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/consensus/statemachine/schemaregion/SchemaExecutionVisitor.java
@@ -436,6 +436,7 @@ public class SchemaExecutionVisitor extends 
PlanVisitor<TSStatus, ISchemaRegion>
   public TSStatus visitBatchActivateTemplate(
       final BatchActivateTemplateNode node, final ISchemaRegion schemaRegion) {
     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 =
@@ -446,10 +447,20 @@ public class SchemaExecutionVisitor extends 
PlanVisitor<TSStatus, ISchemaRegion>
                 entry.getKey(), entry.getValue().right, entry.getValue().left),
             template);
       } catch (final MetadataException e) {
-        logger.error(e.getMessage(), e);
-        statusList.add(RpcUtils.getStatus(e.getErrorCode(), e.getMessage()));
+        if (e.getErrorCode() == 
TSStatusCode.TEMPLATE_IS_IN_USE.getStatusCode()) {
+          alreadyActivatedDeviceList.add(entry.getKey());
+        } else {
+          logger.error(e.getMessage(), e);
+          statusList.add(RpcUtils.getStatus(e.getErrorCode(), e.getMessage()));
+        }
       }
     }
+    if (!alreadyActivatedDeviceList.isEmpty()) {
+      final TemplateIsInUseException e =
+          new TemplateIsInUseException(alreadyActivatedDeviceList.toString());
+      logger.error(e.getMessage(), e);
+      statusList.add(RpcUtils.getStatus(e.getErrorCode(), e.getMessage()));
+    }
     return statusList.isEmpty() ? RpcUtils.SUCCESS_STATUS : 
RpcUtils.getStatus(statusList);
   }
 

Reply via email to