Skip to content

Commit 8ebe276

Browse files
authored
Change UDF creation error code and avoid logging thread stack in warn log (#17467)
1 parent 5b642df commit 8ebe276

5 files changed

Lines changed: 16 additions & 10 deletions

File tree

iotdb-client/service-rpc/src/main/java/org/apache/iotdb/rpc/TSStatusCode.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,7 @@ public enum TSStatusCode {
230230
CREATE_UDF_ERROR(1204),
231231
DROP_UDF_ERROR(1205),
232232
EXECUTE_UDF_ERROR(1206),
233+
UDF_ALREADY_EXISTS(1207),
233234

234235
// Trigger
235236
CREATE_TRIGGER_ERROR(1300),

iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/UDFManager.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import org.apache.iotdb.common.rpc.thrift.TDataNodeLocation;
2525
import org.apache.iotdb.common.rpc.thrift.TSStatus;
2626
import org.apache.iotdb.commons.conf.IoTDBConstant;
27+
import org.apache.iotdb.commons.exception.IoTDBRuntimeException;
2728
import org.apache.iotdb.commons.udf.UDFInformation;
2829
import org.apache.iotdb.commons.udf.UDFType;
2930
import org.apache.iotdb.confignode.client.async.CnToDnAsyncRequestType;
@@ -137,6 +138,8 @@ public TSStatus createFunction(TCreateFunctionReq req) {
137138

138139
LOGGER.info("Start to activate UDF [{}] in UDF_Table on Config Nodes", udfName);
139140
return configManager.getConsensusManager().write(new UpdateFunctionPlan(udfInformation));
141+
} catch (IoTDBRuntimeException e) {
142+
return new TSStatus(e.getErrorCode()).setMessage(e.getMessage());
140143
} catch (Exception e) {
141144
LOGGER.warn(e.getMessage(), e);
142145
return new TSStatus(TSStatusCode.EXECUTE_STATEMENT_ERROR.getStatusCode())

iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/persistence/UDFInfo.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
import org.apache.iotdb.common.rpc.thrift.Model;
2323
import org.apache.iotdb.common.rpc.thrift.TSStatus;
24+
import org.apache.iotdb.commons.exception.IoTDBRuntimeException;
2425
import org.apache.iotdb.commons.executable.ExecutableManager;
2526
import org.apache.iotdb.commons.snapshot.SnapshotProcessor;
2627
import org.apache.iotdb.commons.udf.UDFInformation;
@@ -96,15 +97,17 @@ public void validate(Model model, String udfName, String jarName, String jarMD5)
9697
throws UDFManagementException {
9798
if (udfTable.containsUDF(model, udfName)
9899
&& udfTable.getUDFInformation(model, udfName).isAvailable()) {
99-
throw new UDFManagementException(
100-
String.format("Failed to create UDF [%s], the same name UDF has been created", udfName));
100+
throw new IoTDBRuntimeException(
101+
String.format("Failed to create UDF [%s], the same name UDF has been created", udfName),
102+
TSStatusCode.UDF_ALREADY_EXISTS.getStatusCode());
101103
}
102104

103105
if (existedJarToMD5.containsKey(jarName) && !existedJarToMD5.get(jarName).equals(jarMD5)) {
104-
throw new UDFManagementException(
106+
throw new IoTDBRuntimeException(
105107
String.format(
106108
"Failed to create UDF [%s], the same name Jar [%s] but different MD5 [%s] has existed",
107-
udfName, jarName, jarMD5));
109+
udfName, jarName, jarMD5),
110+
TSStatusCode.UDF_ALREADY_EXISTS.getStatusCode());
108111
}
109112
}
110113

iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/ConfigExecution.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,10 @@ public class ConfigExecution implements IQueryExecution {
7272
TSStatusCode.DATABASE_ALREADY_EXISTS.getStatusCode(),
7373
TSStatusCode.DATABASE_CONFLICT.getStatusCode(),
7474
TSStatusCode.DATABASE_CONFIG_ERROR.getStatusCode(),
75+
TSStatusCode.UDF_LOAD_CLASS_ERROR.getStatusCode(),
76+
TSStatusCode.DROP_UDF_ERROR.getStatusCode(),
77+
TSStatusCode.UDF_DOWNLOAD_ERROR.getStatusCode(),
78+
TSStatusCode.UDF_ALREADY_EXISTS.getStatusCode(),
7579
TSStatusCode.PATH_NOT_EXIST.getStatusCode(),
7680
TSStatusCode.MEASUREMENT_ALREADY_EXISTS_IN_TEMPLATE.getStatusCode(),
7781
TSStatusCode.SCHEMA_QUOTA_EXCEEDED.getStatusCode(),

iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/executor/ClusterConfigTaskExecutor.java

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -604,7 +604,7 @@ public SettableFuture<ConfigTaskResult> createFunction(
604604
String.format(
605605
"Failed to create UDF [%s], the given function name conflicts with the built-in function name.",
606606
udfName.toUpperCase()),
607-
TSStatusCode.CREATE_UDF_ERROR.getStatusCode()));
607+
TSStatusCode.UDF_ALREADY_EXISTS.getStatusCode()));
608608
return future;
609609
}
610610
try (ConfigNodeClient client =
@@ -738,11 +738,6 @@ public SettableFuture<ConfigTaskResult> createFunction(
738738

739739
final TSStatus executionStatus = client.createFunction(tCreateFunctionReq);
740740
if (TSStatusCode.SUCCESS_STATUS.getStatusCode() != executionStatus.getCode()) {
741-
LOGGER.warn(
742-
"Failed to create function {}({}) because {}",
743-
udfName,
744-
className,
745-
executionStatus.getMessage());
746741
future.setException(new IoTDBException(executionStatus));
747742
} else {
748743
future.set(new ConfigTaskResult(TSStatusCode.SUCCESS_STATUS));

0 commit comments

Comments
 (0)