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

jackietien 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 1165497769c Print thread stack for udf execution error
1165497769c is described below

commit 1165497769cd62930422b9b8a1e7200968073a09
Author: Jackie Tien <[email protected]>
AuthorDate: Thu Jul 31 19:50:47 2025 +0800

    Print thread stack for udf execution error
---
 .../db/queryengine/execution/fragment/FragmentInstanceManager.java | 1 +
 .../operator/process/function/TableFunctionLeafOperator.java       | 5 +++++
 .../main/java/org/apache/iotdb/db/utils/ErrorHandlingUtils.java    | 1 +
 .../org/apache/iotdb/commons/exception/IoTDBRuntimeException.java  | 7 +++++++
 4 files changed, 14 insertions(+)

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 89d50ce0264..82ec29cc77c 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
@@ -205,6 +205,7 @@ public class FragmentInstanceManager {
                   } else if (t instanceof UDFTypeMismatchException) {
                     stateMachine.failed(new SemanticException(t.getMessage()));
                   } else if (t instanceof UDFException) {
+                    logger.warn("Exception happened when executing UDTF: ", t);
                     stateMachine.failed(
                         new IoTDBRuntimeException(
                             t.getMessage(), 
TSStatusCode.EXECUTE_UDF_ERROR.getStatusCode(), true));
diff --git 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/function/TableFunctionLeafOperator.java
 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/function/TableFunctionLeafOperator.java
index a52e12358bb..4a8e4d88b88 100644
--- 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/function/TableFunctionLeafOperator.java
+++ 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/function/TableFunctionLeafOperator.java
@@ -32,6 +32,8 @@ import org.apache.tsfile.enums.TSDataType;
 import org.apache.tsfile.read.common.block.TsBlock;
 import org.apache.tsfile.read.common.block.TsBlockBuilder;
 import org.apache.tsfile.read.common.block.column.RunLengthEncodedColumn;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import java.util.Arrays;
 import java.util.List;
@@ -40,6 +42,7 @@ import static 
org.apache.iotdb.db.queryengine.execution.operator.source.relation
 
 // only one input source is supported now
 public class TableFunctionLeafOperator implements ProcessOperator {
+  private static final Logger LOGGER = 
LoggerFactory.getLogger(TableFunctionLeafOperator.class);
 
   private final OperatorContext operatorContext;
   private final TsBlockBuilder blockBuilder;
@@ -76,6 +79,7 @@ public class TableFunctionLeafOperator implements 
ProcessOperator {
     try {
       processor.process(columnBuilders);
     } catch (Exception e) {
+      LOGGER.warn("Exception happened when executing UDTF: ", e);
       throw new IoTDBRuntimeException(
           e.getMessage(), TSStatusCode.EXECUTE_UDF_ERROR.getStatusCode(), 
true);
     }
@@ -103,6 +107,7 @@ public class TableFunctionLeafOperator implements 
ProcessOperator {
     try {
       processor.beforeDestroy();
     } catch (Exception e) {
+      LOGGER.warn("Exception happened when executing UDTF: ", e);
       throw new IoTDBRuntimeException(
           e.getMessage(), TSStatusCode.EXECUTE_UDF_ERROR.getStatusCode(), 
true);
     }
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 62b642f9ae5..e035a4f52bb 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
@@ -120,6 +120,7 @@ public class ErrorHandlingUtils {
             || status.getCode() == 
TSStatusCode.NO_AVAILABLE_REPLICA.getStatusCode()
             || status.getCode() == 
TSStatusCode.CANNOT_FETCH_FI_STATE.getStatusCode()
             || status.getCode() == 
TSStatusCode.QUERY_EXECUTION_MEMORY_NOT_ENOUGH.getStatusCode()
+            || status.getCode() == 
TSStatusCode.EXECUTE_UDF_ERROR.getStatusCode()
             || status.getCode() == TSStatusCode.QUERY_TIMEOUT.getStatusCode()) 
{
           LOGGER.info(message);
         } else {
diff --git 
a/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/exception/IoTDBRuntimeException.java
 
b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/exception/IoTDBRuntimeException.java
index 3d58f7d606b..160ae8b6d82 100644
--- 
a/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/exception/IoTDBRuntimeException.java
+++ 
b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/exception/IoTDBRuntimeException.java
@@ -40,6 +40,13 @@ public class IoTDBRuntimeException extends RuntimeException {
     this.isUserException = isUserException;
   }
 
+  public IoTDBRuntimeException(
+      String message, int errorCode, Throwable cause, boolean isUserException) 
{
+    super(message, cause);
+    this.errorCode = errorCode;
+    this.isUserException = isUserException;
+  }
+
   public IoTDBRuntimeException(String message, Throwable cause, int errorCode) 
{
     super(message, cause);
     this.errorCode = errorCode;

Reply via email to