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 2025/05/20 08:51:16 UTC

(iotdb) branch dev/1.3 updated: Load: fix memory leak when failed to send chunk data in first phase (#15518) (#15542)

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

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


The following commit(s) were added to refs/heads/dev/1.3 by this push:
     new de88b9b336f Load: fix memory leak when failed to send chunk data in first phase (#15518) (#15542)
de88b9b336f is described below

commit de88b9b336f10a4f134f0068ad83bfc34389584b
Author: Zikun Ma <55...@users.noreply.github.com>
AuthorDate: Tue May 20 16:51:11 2025 +0800

    Load: fix memory leak when failed to send chunk data in first phase (#15518) (#15542)
    
    This commit addresses a memory leak issue in the load process by ensuring that memory usage is reduced even when the dispatch of a piece node fails. The key changes include:
    
    - Storing the result of the dispatch call in a variable (isDispatchSuccess) before reducing memory usage.
    - Deducting the memory usage prior to checking the dispatch result to avoid leaks.
    - Returning false immediately after the reduction when the dispatch fails.
    
    (cherry picked from commit 417ddd0becd8f85103d0776d47450f9936241e86)
---
 .../plan/scheduler/load/LoadTsFileScheduler.java           | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

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 f45e9805200..49a9fc9e3be 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
@@ -663,12 +663,8 @@ public class LoadTsFileScheduler implements IScheduler {
           if (pieceNode.getDataSize() == 0) { // total data size has been reduced to 0
             break;
           }
-          if (!scheduler.dispatchOnePieceNode(pieceNode, replicaSet)) {
-            return false;
-          }
+          final boolean isDispatchSuccess = scheduler.dispatchOnePieceNode(pieceNode, replicaSet);
 
-          dataSize -= pieceNode.getDataSize();
-          block.reduceMemoryUsage(pieceNode.getDataSize());
           regionId2ReplicaSetAndNode.replace(
               sortedRegionId,
               new Pair<>(
@@ -678,6 +674,14 @@ public class LoadTsFileScheduler implements IScheduler {
                       singleTsFileNode
                           .getTsFileResource()
                           .getTsFile()))); // can not just remove, because of deletion
+          dataSize -= pieceNode.getDataSize();
+          block.reduceMemoryUsage(pieceNode.getDataSize());
+
+          if (!isDispatchSuccess) {
+            // Currently there is no retry, so return directly
+            return false;
+          }
+
           if (isMemoryEnough()) {
             break;
           }