You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by ja...@apache.org on 2024/09/05 03:19:22 UTC
(iotdb) 01/01: Make status code and error msg be consistent in any case
This is an automated email from the ASF dual-hosted git repository.
jackietien pushed a commit to branch ty/OptSematicErrorPrint
in repository https://gitbox.apache.org/repos/asf/iotdb.git
commit 5527bf98f9c6f41994164a8bfbc4b4ffbf2f16ff
Author: JackieTien97 <ja...@gmail.com>
AuthorDate: Thu Sep 5 11:13:10 2024 +0800
Make status code and error msg be consistent in any case
---
.../old/builtinfunction/scalar/IoTDBSubStringFunctionTableIT.java | 2 +-
.../db/queryengine/execution/fragment/FragmentInstanceManager.java | 3 +++
.../iotdb/db/queryengine/execution/schedule/AbstractDriverThread.java | 4 ++--
.../apache/iotdb/db/queryengine/plan/execution/QueryExecution.java | 2 ++
.../db/queryengine/plan/scheduler/FragmentInstanceDispatcherImpl.java | 4 ++++
.../src/main/java/org/apache/iotdb/db/utils/ErrorHandlingUtils.java | 4 +++-
6 files changed, 15 insertions(+), 4 deletions(-)
diff --git a/integration-test/src/test/java/org/apache/iotdb/relational/it/query/old/builtinfunction/scalar/IoTDBSubStringFunctionTableIT.java b/integration-test/src/test/java/org/apache/iotdb/relational/it/query/old/builtinfunction/scalar/IoTDBSubStringFunctionTableIT.java
index f938e7ffc37..ad32738c958 100644
--- a/integration-test/src/test/java/org/apache/iotdb/relational/it/query/old/builtinfunction/scalar/IoTDBSubStringFunctionTableIT.java
+++ b/integration-test/src/test/java/org/apache/iotdb/relational/it/query/old/builtinfunction/scalar/IoTDBSubStringFunctionTableIT.java
@@ -208,7 +208,7 @@ public class IoTDBSubStringFunctionTableIT {
// Negative characters length
tableAssertTestFail(
"select SUBSTRING(s1 FROM 1 FOR -10) from table1",
- TSStatusCode.EXECUTE_STATEMENT_ERROR.getStatusCode()
+ TSStatusCode.SEMANTIC_ERROR.getStatusCode()
+ ": Argument exception,the scalar function substring length must not be less than 0",
DATABASE_NAME);
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/fragment/FragmentInstanceManager.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/fragment/FragmentInstanceManager.java
index 32500b0baf1..38ff4d3c0f8 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/fragment/FragmentInstanceManager.java
+++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/fragment/FragmentInstanceManager.java
@@ -25,6 +25,7 @@ import org.apache.iotdb.commons.concurrent.ThreadName;
import org.apache.iotdb.commons.concurrent.threadpool.ScheduledExecutorUtil;
import org.apache.iotdb.commons.conf.CommonDescriptor;
import org.apache.iotdb.commons.exception.IoTDBException;
+import org.apache.iotdb.commons.exception.IoTDBRuntimeException;
import org.apache.iotdb.db.conf.IoTDBDescriptor;
import org.apache.iotdb.db.queryengine.common.FragmentInstanceId;
import org.apache.iotdb.db.queryengine.common.QueryId;
@@ -198,6 +199,8 @@ public class FragmentInstanceManager {
new IoTDBException(
TOO_MANY_CONCURRENT_QUERIES_ERROR_MSG,
TOO_MANY_CONCURRENT_QUERIES_ERROR.getStatusCode()));
+ } else if (t instanceof IoTDBRuntimeException) {
+ stateMachine.failed(t);
} else {
logger.warn("error when create FragmentInstanceExecution.", t);
stateMachine.failed(t);
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/schedule/AbstractDriverThread.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/schedule/AbstractDriverThread.java
index b4664703b45..889eed8675f 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/schedule/AbstractDriverThread.java
+++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/schedule/AbstractDriverThread.java
@@ -19,7 +19,7 @@
package org.apache.iotdb.db.queryengine.execution.schedule;
-import org.apache.iotdb.db.exception.sql.SemanticException;
+import org.apache.iotdb.commons.exception.IoTDBRuntimeException;
import org.apache.iotdb.db.queryengine.exception.MemoryNotEnoughException;
import org.apache.iotdb.db.queryengine.execution.schedule.queue.IndexedBlockingQueue;
import org.apache.iotdb.db.queryengine.execution.schedule.task.DriverTask;
@@ -80,7 +80,7 @@ public abstract class AbstractDriverThread extends Thread implements Closeable {
try (SetThreadName driverTaskName =
new SetThreadName(next.getDriver().getDriverTaskId().getFullId())) {
Throwable rootCause = ErrorHandlingUtils.getRootCause(e);
- if (rootCause instanceof SemanticException) {
+ if (rootCause instanceof IoTDBRuntimeException) {
next.setAbortCause(e.getMessage());
} else {
logger.warn("[ExecuteFailed]", e);
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/QueryExecution.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/QueryExecution.java
index ff2509f1d69..2b243a62926 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/QueryExecution.java
+++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/QueryExecution.java
@@ -73,6 +73,7 @@ import static org.apache.iotdb.db.queryengine.common.DataNodeEndPoints.isSameNod
import static org.apache.iotdb.db.queryengine.metric.QueryExecutionMetricSet.WAIT_FOR_RESULT;
import static org.apache.iotdb.db.queryengine.metric.QueryPlanCostMetricSet.DISTRIBUTION_PLANNER;
import static org.apache.iotdb.db.queryengine.metric.QueryPlanCostMetricSet.TREE_TYPE;
+import static org.apache.iotdb.db.utils.ErrorHandlingUtils.getRootCause;
/**
* QueryExecution stores all the status of a query which is being prepared or running inside the MPP
@@ -480,6 +481,7 @@ public class QueryExecution implements IQueryExecution {
}
private void dealWithException(Throwable t) throws IoTDBException {
+ t = getRootCause(t);
stateMachine.transitionToFailed(t);
if (stateMachine.getFailureStatus() != null) {
throw new IoTDBException(
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/scheduler/FragmentInstanceDispatcherImpl.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/scheduler/FragmentInstanceDispatcherImpl.java
index 7b4a4e30490..6f695b41ac8 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/scheduler/FragmentInstanceDispatcherImpl.java
+++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/scheduler/FragmentInstanceDispatcherImpl.java
@@ -338,6 +338,8 @@ public class FragmentInstanceDispatcherImpl implements IFragInstanceDispatcher {
== TSStatusCode.TOO_MANY_CONCURRENT_QUERIES_ERROR.getStatusCode()) {
throw new FragmentInstanceDispatchException(sendFragmentInstanceResp.status);
}
+ } else if (sendFragmentInstanceResp.status != null) {
+ throw new FragmentInstanceDispatchException(sendFragmentInstanceResp.status);
}
throw new FragmentInstanceDispatchException(
RpcUtils.getStatus(
@@ -463,6 +465,8 @@ public class FragmentInstanceDispatcherImpl implements IFragInstanceDispatcher {
}
throw new FragmentInstanceDispatchException(
RpcUtils.getStatus(TSStatusCode.DISPATCH_ERROR, readResult.getMessage()));
+ } else if (readResult.getStatus() != null) {
+ throw new FragmentInstanceDispatchException(readResult.getStatus());
} else {
throw new FragmentInstanceDispatchException(
RpcUtils.getStatus(TSStatusCode.EXECUTE_STATEMENT_ERROR, readResult.getMessage()));
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/utils/ErrorHandlingUtils.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/utils/ErrorHandlingUtils.java
index f527d068ee1..163f179b57c 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/utils/ErrorHandlingUtils.java
+++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/utils/ErrorHandlingUtils.java
@@ -103,7 +103,9 @@ public class ErrorHandlingUtils {
if (status.getCode() == TSStatusCode.SQL_PARSE_ERROR.getStatusCode()
|| status.getCode() == TSStatusCode.SEMANTIC_ERROR.getStatusCode()
|| status.getCode() == TSStatusCode.NO_PERMISSION.getStatusCode()
- || status.getCode() == TSStatusCode.ILLEGAL_PATH.getStatusCode()) {
+ || status.getCode() == TSStatusCode.ILLEGAL_PATH.getStatusCode()
+ || status.getCode() == TSStatusCode.NUMERIC_VALUE_OUT_OF_RANGE.getStatusCode()
+ || status.getCode() == TSStatusCode.DIVISION_BY_ZERO.getStatusCode()) {
LOGGER.warn(message);
} else {
LOGGER.warn(message, e);