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 2022/04/22 02:33:18 UTC

[iotdb] branch master updated: Add block cancel when GetBlockTask throws exception (#5628)

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

jackietien 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 6952eed0e6 Add block cancel when GetBlockTask throws exception (#5628)
6952eed0e6 is described below

commit 6952eed0e6dd2a884ee6df43a46fca0982ebcea0
Author: Zhang.Jinrui <xi...@gmail.com>
AuthorDate: Fri Apr 22 10:33:13 2022 +0800

    Add block cancel when GetBlockTask throws exception (#5628)
---
 .../src/main/java/org/apache/iotdb/db/mpp/buffer/SourceHandle.java  | 6 ++++++
 .../main/java/org/apache/iotdb/db/mpp/execution/QueryExecution.java | 3 ++-
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/server/src/main/java/org/apache/iotdb/db/mpp/buffer/SourceHandle.java b/server/src/main/java/org/apache/iotdb/db/mpp/buffer/SourceHandle.java
index 1d6b92d25e..b249cb78d7 100644
--- a/server/src/main/java/org/apache/iotdb/db/mpp/buffer/SourceHandle.java
+++ b/server/src/main/java/org/apache/iotdb/db/mpp/buffer/SourceHandle.java
@@ -357,6 +357,12 @@ public class SourceHandle implements ISourceHandle {
               localMemoryManager
                   .getQueryPool()
                   .free(localFragmentInstanceId.getQueryId(), reservedBytes);
+              // That GetDataBlocksTask throws exception means some TsBlock cannot be
+              // fetched permanently. Someone maybe waiting the SourceHandle to be
+              // unblocked after fetching data. So the blocked should be released.
+              if (blocked != null && !blocked.isDone()) {
+                blocked.cancel(true);
+              }
             }
           }
         }
diff --git a/server/src/main/java/org/apache/iotdb/db/mpp/execution/QueryExecution.java b/server/src/main/java/org/apache/iotdb/db/mpp/execution/QueryExecution.java
index f362a48a72..ad9a1c170a 100644
--- a/server/src/main/java/org/apache/iotdb/db/mpp/execution/QueryExecution.java
+++ b/server/src/main/java/org/apache/iotdb/db/mpp/execution/QueryExecution.java
@@ -50,6 +50,7 @@ import java.io.IOException;
 import java.sql.SQLException;
 import java.util.ArrayList;
 import java.util.List;
+import java.util.concurrent.CancellationException;
 import java.util.concurrent.ExecutionException;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.ScheduledExecutorService;
@@ -210,7 +211,7 @@ public class QueryExecution implements IQueryExecution {
       }
       return resultHandle.receive();
 
-    } catch (ExecutionException | IOException e) {
+    } catch (ExecutionException | IOException | CancellationException e) {
       stateMachine.transitionToFailed(e);
       throwIfUnchecked(e.getCause());
       throw new RuntimeException(e.getCause());