You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by ja...@apache.org on 2023/04/06 08:26:33 UTC

[iotdb] branch ContextReleaseResourceNPE1.1 created (now 3f6ffe0c48)

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

jackietien pushed a change to branch ContextReleaseResourceNPE1.1
in repository https://gitbox.apache.org/repos/asf/iotdb.git


      at 3f6ffe0c48 Fix Context release source NPE

This branch includes the following new commits:

     new 3f6ffe0c48 Fix Context release source NPE

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[iotdb] 01/01: Fix Context release source NPE

Posted by ja...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

jackietien pushed a commit to branch ContextReleaseResourceNPE1.1
in repository https://gitbox.apache.org/repos/asf/iotdb.git

commit 3f6ffe0c4840df55dea6b5607f8e2f73a489f3ba
Author: Jackie Tien <ja...@gmail.com>
AuthorDate: Thu Apr 6 15:26:39 2023 +0800

    Fix Context release source NPE
    
    (cherry picked from commit 69f2693995a591d6453ab2dfe95b19d075b88ed8)
---
 .../execution/fragment/FragmentInstanceContext.java   | 19 +++++++++++++------
 .../execution/fragment/FragmentInstanceExecution.java |  5 +++++
 2 files changed, 18 insertions(+), 6 deletions(-)

diff --git a/server/src/main/java/org/apache/iotdb/db/mpp/execution/fragment/FragmentInstanceContext.java b/server/src/main/java/org/apache/iotdb/db/mpp/execution/fragment/FragmentInstanceContext.java
index f810bc1ddb..7e6257ef20 100644
--- a/server/src/main/java/org/apache/iotdb/db/mpp/execution/fragment/FragmentInstanceContext.java
+++ b/server/src/main/java/org/apache/iotdb/db/mpp/execution/fragment/FragmentInstanceContext.java
@@ -355,14 +355,21 @@ public class FragmentInstanceContext extends QueryContext {
    * be decreased.
    */
   protected synchronized void releaseResource() {
-    for (TsFileResource tsFile : closedFilePaths) {
-      FileReaderManager.getInstance().decreaseFileReaderReference(tsFile, true);
+    // For schema related query FI, closedFilePaths and unClosedFilePaths will be null
+    if (closedFilePaths != null) {
+      for (TsFileResource tsFile : closedFilePaths) {
+        FileReaderManager.getInstance().decreaseFileReaderReference(tsFile, true);
+      }
+      closedFilePaths = null;
     }
-    closedFilePaths = null;
-    for (TsFileResource tsFile : unClosedFilePaths) {
-      FileReaderManager.getInstance().decreaseFileReaderReference(tsFile, false);
+
+    if (unClosedFilePaths != null) {
+      for (TsFileResource tsFile : unClosedFilePaths) {
+        FileReaderManager.getInstance().decreaseFileReaderReference(tsFile, false);
+      }
+      unClosedFilePaths = null;
     }
-    unClosedFilePaths = null;
+
     dataRegion = null;
     timeFilter = null;
     sourcePaths = null;
diff --git a/server/src/main/java/org/apache/iotdb/db/mpp/execution/fragment/FragmentInstanceExecution.java b/server/src/main/java/org/apache/iotdb/db/mpp/execution/fragment/FragmentInstanceExecution.java
index f9c17c9963..22377fc9ad 100644
--- a/server/src/main/java/org/apache/iotdb/db/mpp/execution/fragment/FragmentInstanceExecution.java
+++ b/server/src/main/java/org/apache/iotdb/db/mpp/execution/fragment/FragmentInstanceExecution.java
@@ -140,6 +140,11 @@ public class FragmentInstanceExecution {
             if (newState.isFailed()) {
               scheduler.abortFragmentInstance(instanceId);
             }
+          } catch (Throwable t) {
+            try (SetThreadName threadName = new SetThreadName(instanceId.getFullId())) {
+              LOGGER.error(
+                  "Errors happened while trying to finish FI, resource may already leak!", t);
+            }
           }
         });
   }