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

haonan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/iotdb.git


The following commit(s) were added to refs/heads/master by this push:
     new b7af23a4bd [IOTDB-3636] Fix delete non existing sg error msg (#6478)
b7af23a4bd is described below

commit b7af23a4bdf4a8c805af46f5d159f1ecf0f8ea12
Author: Marcos_Zyk <[email protected]>
AuthorDate: Tue Jun 28 14:50:59 2022 +0800

    [IOTDB-3636] Fix delete non existing sg error msg (#6478)
---
 .../apache/iotdb/confignode/manager/ConfigManager.java    |  6 ++++++
 .../config/executor/ClusterConfigTaskExecutor.java        |  2 +-
 .../config/executor/StandaloneConfigTaskExecutor.java     | 15 ++++++++++++++-
 3 files changed, 21 insertions(+), 2 deletions(-)

diff --git 
a/confignode/src/main/java/org/apache/iotdb/confignode/manager/ConfigManager.java
 
b/confignode/src/main/java/org/apache/iotdb/confignode/manager/ConfigManager.java
index 69f5325db0..88db72bf78 100644
--- 
a/confignode/src/main/java/org/apache/iotdb/confignode/manager/ConfigManager.java
+++ 
b/confignode/src/main/java/org/apache/iotdb/confignode/manager/ConfigManager.java
@@ -84,6 +84,7 @@ import org.slf4j.LoggerFactory;
 
 import java.io.IOException;
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.HashSet;
@@ -268,6 +269,11 @@ public class ConfigManager implements IManager {
       // remove wild
       Map<String, TStorageGroupSchema> deleteStorageSchemaMap =
           
getClusterSchemaManager().getMatchedStorageGroupSchemasByName(deletedPaths);
+      if (deleteStorageSchemaMap.isEmpty()) {
+        return RpcUtils.getStatus(
+            TSStatusCode.TIMESERIES_NOT_EXIST.getStatusCode(),
+            String.format("Path %s does not exist", 
Arrays.toString(deletedPaths.toArray())));
+      }
       ArrayList<TStorageGroupSchema> parsedDeleteStorageGroups =
           new ArrayList<>(deleteStorageSchemaMap.values());
       return procedureManager.deleteStorageGroups(parsedDeleteStorageGroups);
diff --git 
a/server/src/main/java/org/apache/iotdb/db/mpp/plan/execution/config/executor/ClusterConfigTaskExecutor.java
 
b/server/src/main/java/org/apache/iotdb/db/mpp/plan/execution/config/executor/ClusterConfigTaskExecutor.java
index d4a16138e2..71edb2af9b 100644
--- 
a/server/src/main/java/org/apache/iotdb/db/mpp/plan/execution/config/executor/ClusterConfigTaskExecutor.java
+++ 
b/server/src/main/java/org/apache/iotdb/db/mpp/plan/execution/config/executor/ClusterConfigTaskExecutor.java
@@ -194,7 +194,7 @@ public class ClusterConfigTaskExecutor implements 
IConfigTaskExecutor {
             "Failed to execute delete storage group {} in config node, status 
is {}.",
             deleteStorageGroupStatement.getPrefixPath(),
             tsStatus);
-        future.setException(new StatementExecutionException(tsStatus));
+        future.setException(new IoTDBException(tsStatus.getMessage(), 
tsStatus.getCode()));
       } else {
         future.set(new ConfigTaskResult(TSStatusCode.SUCCESS_STATUS));
       }
diff --git 
a/server/src/main/java/org/apache/iotdb/db/mpp/plan/execution/config/executor/StandaloneConfigTaskExecutor.java
 
b/server/src/main/java/org/apache/iotdb/db/mpp/plan/execution/config/executor/StandaloneConfigTaskExecutor.java
index dd6b760e93..53da4960f0 100644
--- 
a/server/src/main/java/org/apache/iotdb/db/mpp/plan/execution/config/executor/StandaloneConfigTaskExecutor.java
+++ 
b/server/src/main/java/org/apache/iotdb/db/mpp/plan/execution/config/executor/StandaloneConfigTaskExecutor.java
@@ -21,6 +21,7 @@ package 
org.apache.iotdb.db.mpp.plan.execution.config.executor;
 
 import org.apache.iotdb.common.rpc.thrift.TFlushReq;
 import org.apache.iotdb.common.rpc.thrift.TSStatus;
+import org.apache.iotdb.commons.exception.IoTDBException;
 import org.apache.iotdb.commons.exception.MetadataException;
 import org.apache.iotdb.commons.path.PartialPath;
 import org.apache.iotdb.commons.udf.service.UDFExecutableManager;
@@ -49,6 +50,7 @@ import org.slf4j.LoggerFactory;
 
 import java.io.IOException;
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -164,9 +166,20 @@ public class StandaloneConfigTaskExecutor implements 
IConfigTaskExecutor {
         deletePathList.addAll(
             LocalConfigNode.getInstance().getMatchedStorageGroups(prefixPath, 
false));
       }
-      LocalConfigNode.getInstance().deleteStorageGroups(deletePathList);
+      if (deletePathList.isEmpty()) {
+        future.setException(
+            new IoTDBException(
+                String.format(
+                    "Path %s does not exist",
+                    
Arrays.toString(deleteStorageGroupStatement.getPrefixPath().toArray())),
+                TSStatusCode.TIMESERIES_NOT_EXIST.getStatusCode()));
+        return future;
+      } else {
+        LocalConfigNode.getInstance().deleteStorageGroups(deletePathList);
+      }
     } catch (MetadataException e) {
       future.setException(e);
+      return future;
     }
     future.set(new ConfigTaskResult(TSStatusCode.SUCCESS_STATUS));
     return future;

Reply via email to