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 03:35:09 UTC

[iotdb] branch ContextReleaseResourceNPE created (now 693fa46e34)

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

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


      at 693fa46e34 Fix Context release source NPE

This branch includes the following new commits:

     new 693fa46e34 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 ContextReleaseResourceNPE
in repository https://gitbox.apache.org/repos/asf/iotdb.git

commit 693fa46e34329ac3dd5e69e7a06c1b8454f7279c
Author: JackieTien97 <ja...@gmail.com>
AuthorDate: Thu Apr 6 11:34:55 2023 +0800

    Fix Context release source NPE
---
 .../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 b402f0892e..c50c47c41f 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
@@ -145,6 +145,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);
+            }
           }
         });
   }