You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by ro...@apache.org on 2022/01/10 05:09:43 UTC

[iotdb] branch iotdb-2267 updated (cb4258b -> e5d9eff)

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

rong pushed a change to branch iotdb-2267
in repository https://gitbox.apache.org/repos/asf/iotdb.git.


    from cb4258b  [IOTDB-2267] Error code 500 caused by org.apache.iotdb.udf.UDTFExample
     new 755d7af  fix comments
     new e5d9eff  fix tryCatchQueryException

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../java/org/apache/iotdb/udf/UDTFExample.java     |  2 +-
 .../apache/iotdb/db/utils/ErrorHandlingUtils.java  | 47 ++++++++++++----------
 2 files changed, 26 insertions(+), 23 deletions(-)

[iotdb] 02/02: fix tryCatchQueryException

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit e5d9eff82a93c96c58f5631298693b35e0ac3c3e
Author: Steve Yurong Su <ro...@apache.org>
AuthorDate: Mon Jan 10 13:08:55 2022 +0800

    fix tryCatchQueryException
---
 .../apache/iotdb/db/utils/ErrorHandlingUtils.java  | 47 ++++++++++++----------
 1 file changed, 25 insertions(+), 22 deletions(-)

diff --git a/server/src/main/java/org/apache/iotdb/db/utils/ErrorHandlingUtils.java b/server/src/main/java/org/apache/iotdb/db/utils/ErrorHandlingUtils.java
index 80b4285..bebe345 100644
--- a/server/src/main/java/org/apache/iotdb/db/utils/ErrorHandlingUtils.java
+++ b/server/src/main/java/org/apache/iotdb/db/utils/ErrorHandlingUtils.java
@@ -35,7 +35,9 @@ import org.antlr.v4.runtime.misc.ParseCancellationException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import java.io.IOException;
 import java.util.Arrays;
+import java.util.concurrent.ExecutionException;
 
 public class ErrorHandlingUtils {
 
@@ -53,7 +55,7 @@ public class ErrorHandlingUtils {
   public static TSStatus onNPEOrUnexpectedException(
       Exception e, String operation, TSStatusCode statusCode) {
     String message = String.format("[%s] Exception occurred: %s failed. ", statusCode, operation);
-    if (e instanceof NullPointerException) {
+    if (e instanceof IOException || e instanceof NullPointerException) {
       LOGGER.error("Status code: {}, operation: {} failed", statusCode, operation, e);
     } else {
       LOGGER.warn("Status code: {}, operation: {} failed", statusCode, operation, e);
@@ -85,31 +87,32 @@ public class ErrorHandlingUtils {
   }
 
   public static TSStatus tryCatchQueryException(Exception e) {
-    if (e instanceof QueryTimeoutRuntimeException) {
-      DETAILED_FAILURE_QUERY_TRACE_LOGGER.warn(e.getMessage(), e);
-      return RpcUtils.getStatus(TSStatusCode.TIME_OUT, getRootCause(e));
-    } else if (e instanceof ParseCancellationException) {
-      DETAILED_FAILURE_QUERY_TRACE_LOGGER.warn(INFO_PARSING_SQL_ERROR, e);
+    Throwable t = e instanceof ExecutionException ? e.getCause() : e;
+    if (t instanceof QueryTimeoutRuntimeException) {
+      DETAILED_FAILURE_QUERY_TRACE_LOGGER.warn(t.getMessage(), t);
+      return RpcUtils.getStatus(TSStatusCode.TIME_OUT, getRootCause(t));
+    } else if (t instanceof ParseCancellationException) {
+      DETAILED_FAILURE_QUERY_TRACE_LOGGER.warn(INFO_PARSING_SQL_ERROR, t);
       return RpcUtils.getStatus(
-          TSStatusCode.SQL_PARSE_ERROR, INFO_PARSING_SQL_ERROR + getRootCause(e));
-    } else if (e instanceof SQLParserException) {
-      DETAILED_FAILURE_QUERY_TRACE_LOGGER.warn(INFO_CHECK_METADATA_ERROR, e);
+          TSStatusCode.SQL_PARSE_ERROR, INFO_PARSING_SQL_ERROR + getRootCause(t));
+    } else if (t instanceof SQLParserException) {
+      DETAILED_FAILURE_QUERY_TRACE_LOGGER.warn(INFO_CHECK_METADATA_ERROR, t);
       return RpcUtils.getStatus(
-          TSStatusCode.METADATA_ERROR, INFO_CHECK_METADATA_ERROR + getRootCause(e));
-    } else if (e instanceof QueryProcessException) {
-      DETAILED_FAILURE_QUERY_TRACE_LOGGER.warn(INFO_QUERY_PROCESS_ERROR, e);
+          TSStatusCode.METADATA_ERROR, INFO_CHECK_METADATA_ERROR + getRootCause(t));
+    } else if (t instanceof QueryProcessException) {
+      DETAILED_FAILURE_QUERY_TRACE_LOGGER.warn(INFO_QUERY_PROCESS_ERROR, t);
       return RpcUtils.getStatus(
-          TSStatusCode.QUERY_PROCESS_ERROR, INFO_QUERY_PROCESS_ERROR + getRootCause(e));
-    } else if (e instanceof QueryInBatchStatementException) {
-      DETAILED_FAILURE_QUERY_TRACE_LOGGER.warn(INFO_NOT_ALLOWED_IN_BATCH_ERROR, e);
+          TSStatusCode.QUERY_PROCESS_ERROR, INFO_QUERY_PROCESS_ERROR + getRootCause(t));
+    } else if (t instanceof QueryInBatchStatementException) {
+      DETAILED_FAILURE_QUERY_TRACE_LOGGER.warn(INFO_NOT_ALLOWED_IN_BATCH_ERROR, t);
       return RpcUtils.getStatus(
-          TSStatusCode.QUERY_NOT_ALLOWED, INFO_NOT_ALLOWED_IN_BATCH_ERROR + getRootCause(e));
-    } else if (e instanceof IoTDBException && !(e instanceof StorageGroupNotReadyException)) {
-      DETAILED_FAILURE_QUERY_TRACE_LOGGER.warn(INFO_QUERY_PROCESS_ERROR, e);
-      return RpcUtils.getStatus(((IoTDBException) e).getErrorCode(), getRootCause(e));
-    } else if (e instanceof TsFileRuntimeException) {
-      DETAILED_FAILURE_QUERY_TRACE_LOGGER.warn(INFO_QUERY_PROCESS_ERROR, e);
-      return RpcUtils.getStatus(TSStatusCode.TSFILE_PROCESSOR_ERROR, getRootCause(e));
+          TSStatusCode.QUERY_NOT_ALLOWED, INFO_NOT_ALLOWED_IN_BATCH_ERROR + getRootCause(t));
+    } else if (t instanceof IoTDBException && !(t instanceof StorageGroupNotReadyException)) {
+      DETAILED_FAILURE_QUERY_TRACE_LOGGER.warn(INFO_QUERY_PROCESS_ERROR, t);
+      return RpcUtils.getStatus(((IoTDBException) t).getErrorCode(), getRootCause(t));
+    } else if (t instanceof TsFileRuntimeException) {
+      DETAILED_FAILURE_QUERY_TRACE_LOGGER.warn(INFO_QUERY_PROCESS_ERROR, t);
+      return RpcUtils.getStatus(TSStatusCode.TSFILE_PROCESSOR_ERROR, getRootCause(t));
     }
     return null;
   }

[iotdb] 01/02: fix comments

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 755d7afa04ee00df4cea3486a7ff322c4141a82c
Author: Steve Yurong Su <ro...@apache.org>
AuthorDate: Mon Jan 10 12:01:39 2022 +0800

    fix comments
---
 example/udf/src/main/java/org/apache/iotdb/udf/UDTFExample.java | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/example/udf/src/main/java/org/apache/iotdb/udf/UDTFExample.java b/example/udf/src/main/java/org/apache/iotdb/udf/UDTFExample.java
index 9772a2b..66a0748 100644
--- a/example/udf/src/main/java/org/apache/iotdb/udf/UDTFExample.java
+++ b/example/udf/src/main/java/org/apache/iotdb/udf/UDTFExample.java
@@ -41,7 +41,7 @@ public class UDTFExample implements UDTF {
    * INSERT INTO root.sg1.d1(timestamp, s1, s2) VALUES (1, -2, 2);
    * INSERT INTO root.sg1.d1(timestamp, s1, s2) VALUES (2, -3, 3);
    *
-   * CREATE FUNCTION example AS "org.apache.iotdb.udf.UDTFExample";
+   * CREATE FUNCTION example AS 'org.apache.iotdb.udf.UDTFExample';
    * SHOW FUNCTIONS;
    * SELECT s1, example(s1), s2, example(s2) FROM root.sg1.d1;
    */