This is an automated email from the ASF dual-hosted git repository. JackieTien97 pushed a commit to branch ty/reduce-query-warn-log in repository https://gitbox.apache.org/repos/asf/iotdb.git
commit 47593c628ae5012eabe563099e07ec066be9559f Author: JackieTien97 <[email protected]> AuthorDate: Thu Aug 6 17:06:37 2026 +0800 Reduce query execution warning log size --- .../execution/schedule/AbstractDriverThread.java | 26 ++++++++-- .../schemaregion/utils/ResourceByPathUtils.java | 4 +- .../schedule/AbstractDriverThreadTest.java | 60 ++++++++++++++++++++++ 3 files changed, 83 insertions(+), 7 deletions(-) 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 ce30549c78d..f07cb647ad4 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,6 +19,8 @@ package org.apache.iotdb.db.queryengine.execution.schedule; +import org.apache.iotdb.commons.exception.IoTDBException; +import org.apache.iotdb.commons.exception.IoTDBRuntimeException; import org.apache.iotdb.commons.utils.ErrorHandlingCommonUtils; import org.apache.iotdb.db.queryengine.exception.MemoryNotEnoughException; import org.apache.iotdb.db.queryengine.execution.schedule.queue.IndexedBlockingQueue; @@ -30,6 +32,7 @@ import org.slf4j.LoggerFactory; import java.io.Closeable; import java.io.IOException; +import java.time.format.DateTimeParseException; /** An abstract executor for {@link DriverTask}. */ public abstract class AbstractDriverThread extends Thread implements Closeable { @@ -78,8 +81,13 @@ public abstract class AbstractDriverThread extends Thread implements Closeable { // reset the thread name here try (SetThreadName driverTaskName = new SetThreadName(next.getDriver().getDriverTaskId().getFullId())) { - logger.warn("[ExecuteFailed]", e); - next.setAbortCause(getAbortCause(e)); + Throwable rootCause = ErrorHandlingCommonUtils.getRootCause(e); + if (isExpectedException(rootCause)) { + next.setAbortCause(getAbortCause(rootCause)); + } else { + logger.warn("[ExecuteFailed]", rootCause); + next.setAbortCause(DriverTaskAbortedException.BY_INTERNAL_ERROR_SCHEDULED); + } scheduler.toAborted(next); } } finally { @@ -116,11 +124,19 @@ public abstract class AbstractDriverThread extends Thread implements Closeable { closed = true; } - private String getAbortCause(final Exception e) { - Throwable rootCause = ErrorHandlingCommonUtils.getRootCause(e); + static boolean isExpectedException(Throwable rootCause) { + return rootCause instanceof MemoryNotEnoughException + || rootCause instanceof IoTDBRuntimeException + || rootCause instanceof IoTDBException + || rootCause instanceof DateTimeParseException; + } + + static String getAbortCause(final Throwable rootCause) { if (rootCause instanceof MemoryNotEnoughException) { return DriverTaskAbortedException.BY_MEMORY_NOT_ENOUGH; } - return DriverTaskAbortedException.BY_INTERNAL_ERROR_SCHEDULED; + return rootCause.getMessage() == null + ? rootCause.getClass().getSimpleName() + : rootCause.getMessage(); } } diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/schemaengine/schemaregion/utils/ResourceByPathUtils.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/schemaengine/schemaregion/utils/ResourceByPathUtils.java index fa2f603d6fa..e703c08d51b 100644 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/schemaengine/schemaregion/utils/ResourceByPathUtils.java +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/schemaengine/schemaregion/utils/ResourceByPathUtils.java @@ -239,12 +239,12 @@ public abstract class ResourceByPathUtils { } } catch (MemoryNotEnoughException ex) { LOGGER.warn( - "Failed to reserve memory for TVList: ramSize {}, timestampsSize {}, arrayMemCost {}, rowCount {}, dataTypes {}", + "Failed to reserve memory for TVList: ramSize {}, timestampsSize {}, arrayMemCost {}, rowCount {}, dataTypeCount {}", listRamInfo.getRamSize(), listRamInfo.getTimestampsSize(), listRamInfo.getArrayMemCost(), listRamInfo.getRowCount(), - listRamInfo.getDataTypes()); + listRamInfo.getDataTypes().size()); throw ex; } finally { list.unlockQueryList(); diff --git a/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/queryengine/execution/schedule/AbstractDriverThreadTest.java b/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/queryengine/execution/schedule/AbstractDriverThreadTest.java new file mode 100644 index 00000000000..8a86134a07b --- /dev/null +++ b/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/queryengine/execution/schedule/AbstractDriverThreadTest.java @@ -0,0 +1,60 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.iotdb.db.queryengine.execution.schedule; + +import org.apache.iotdb.commons.exception.IoTDBException; +import org.apache.iotdb.commons.exception.IoTDBRuntimeException; +import org.apache.iotdb.db.queryengine.exception.MemoryNotEnoughException; + +import org.junit.Test; + +import java.time.format.DateTimeParseException; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +public class AbstractDriverThreadTest { + + @Test + public void testExpectedExceptionClassification() { + assertTrue(AbstractDriverThread.isExpectedException(new MemoryNotEnoughException("no memory"))); + assertTrue(AbstractDriverThread.isExpectedException(new IoTDBRuntimeException("known", 500))); + assertTrue(AbstractDriverThread.isExpectedException(new IoTDBException("known", 500))); + assertTrue( + AbstractDriverThread.isExpectedException( + new DateTimeParseException("invalid date", "invalid", 0))); + + assertFalse(AbstractDriverThread.isExpectedException(new IllegalStateException("unknown"))); + } + + @Test + public void testAbortCauseForExpectedException() { + assertEquals( + DriverTaskAbortedException.BY_MEMORY_NOT_ENOUGH, + AbstractDriverThread.getAbortCause(new MemoryNotEnoughException("no memory"))); + assertEquals( + "known error", + AbstractDriverThread.getAbortCause(new IoTDBRuntimeException("known error", 500))); + assertEquals( + "IoTDBException", + AbstractDriverThread.getAbortCause(new IoTDBException((String) null, 500))); + } +}
