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

rong 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 06ccdd163d0 Load: fix memory leak when failed in 2nd phase (#15503)
06ccdd163d0 is described below

commit 06ccdd163d0c7579d4ed2015686de6ada91c7681
Author: Zikun Ma <[email protected]>
AuthorDate: Thu May 15 16:59:27 2025 +0800

    Load: fix memory leak when failed in 2nd phase (#15503)
---
 .../receiver/protocol/thrift/IoTDBDataNodeReceiver.java    |  6 ++++--
 .../plan/scheduler/load/LoadTsFileScheduler.java           | 14 +++++++++-----
 .../commons/pipe/datastructure/pattern/TablePattern.java   |  4 ++--
 3 files changed, 15 insertions(+), 9 deletions(-)

diff --git 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/receiver/protocol/thrift/IoTDBDataNodeReceiver.java
 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/receiver/protocol/thrift/IoTDBDataNodeReceiver.java
index 5ba383eb885..b462fb8d36b 100644
--- 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/receiver/protocol/thrift/IoTDBDataNodeReceiver.java
+++ 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/receiver/protocol/thrift/IoTDBDataNodeReceiver.java
@@ -798,11 +798,13 @@ public class IoTDBDataNodeReceiver extends 
IoTDBFileReceiver {
     } catch (final PipeRuntimeOutOfMemoryCriticalException e) {
       final String message =
           String.format(
-              "Temporarily out of memory when executing statement %s, 
Requested memory: %s, used memory: %s, total memory: %s",
+              "Temporarily out of memory when executing statement %s, 
Requested memory: %s, "
+                  + "used memory: %s, free memory: %s, total non-floating 
memory: %s",
               statement,
               estimatedMemory * pipeReceiverActualToEstimatedMemoryRatio,
               PipeDataNodeResourceManager.memory().getUsedMemorySizeInBytes(),
-              PipeDataNodeResourceManager.memory().getFreeMemorySizeInBytes());
+              PipeDataNodeResourceManager.memory().getFreeMemorySizeInBytes(),
+              
PipeDataNodeResourceManager.memory().getTotalNonFloatingMemorySizeInBytes());
       if (LOGGER.isDebugEnabled()) {
         LOGGER.debug("Receiver id = {}: {}", receiverId.get(), message, e);
       }
diff --git 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/scheduler/load/LoadTsFileScheduler.java
 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/scheduler/load/LoadTsFileScheduler.java
index 84ee70446ef..d77f696ad7f 100644
--- 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/scheduler/load/LoadTsFileScheduler.java
+++ 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/scheduler/load/LoadTsFileScheduler.java
@@ -425,7 +425,9 @@ public class LoadTsFileScheduler implements IScheduler {
             result.getFailureStatus().getMessage());
         TSStatus status = result.getFailureStatus();
         status.setMessage(
-            String.format("Load %s error in 2nd phase. Because ", tsFile) + 
status.getMessage());
+            String.format(
+                "Load %s error in second phase. Because %s, first phase is %s",
+                tsFile, status.getMessage(), isFirstPhaseSuccess ? "success" : 
"failed"));
         stateMachine.transitionToFailed(status);
         return false;
       }
@@ -780,19 +782,21 @@ public class LoadTsFileScheduler implements IScheduler {
     private boolean sendAllTsFileData() throws LoadFileException {
       routeChunkData();
 
+      boolean isAllSuccess = true;
       for (Map.Entry<TConsensusGroupId, Pair<TRegionReplicaSet, 
LoadTsFilePieceNode>> entry :
           regionId2ReplicaSetAndNode.entrySet()) {
         block.reduceMemoryUsage(entry.getValue().getRight().getDataSize());
-        if (!scheduler.dispatchOnePieceNode(
-            entry.getValue().getRight(), entry.getValue().getLeft())) {
+        if (isAllSuccess
+            && !scheduler.dispatchOnePieceNode(
+                entry.getValue().getRight(), entry.getValue().getLeft())) {
           LOGGER.warn(
               "Dispatch piece node {} of TsFile {} error.",
               entry.getValue(),
               singleTsFileNode.getTsFileResource().getTsFile());
-          return false;
+          isAllSuccess = false;
         }
       }
-      return true;
+      return isAllSuccess;
     }
 
     private void clear() {
diff --git 
a/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/pipe/datastructure/pattern/TablePattern.java
 
b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/pipe/datastructure/pattern/TablePattern.java
index 34848ac4665..6efc7499015 100644
--- 
a/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/pipe/datastructure/pattern/TablePattern.java
+++ 
b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/pipe/datastructure/pattern/TablePattern.java
@@ -151,9 +151,9 @@ public class TablePattern {
   @Override
   public String toString() {
     return "TablePattern{"
-        + "isTableModelDataAllowedToBeCaptured"
+        + "isTableModelDataAllowedToBeCaptured="
         + isTableModelDataAllowedToBeCaptured
-        + "databasePattern="
+        + ", databasePattern="
         + databasePattern
         + ", tablePattern="
         + tablePattern

Reply via email to