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/25 11:07:11 UTC

[iotdb] branch master updated: fix the issue that FragmentInstance's status cannot be updated to FINISHED in some scenario (#5660)

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 3d040c9855 fix the issue that FragmentInstance's status cannot be updated to FINISHED in some scenario (#5660)
3d040c9855 is described below

commit 3d040c9855ec6c96459c92838e7c8c74f0be09ee
Author: Zhang.Jinrui <xi...@gmail.com>
AuthorDate: Mon Apr 25 19:07:05 2022 +0800

    fix the issue that FragmentInstance's status cannot be updated to FINISHED in some scenario (#5660)
---
 .../main/java/org/apache/iotdb/db/mpp/buffer/SinkHandle.java  | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/server/src/main/java/org/apache/iotdb/db/mpp/buffer/SinkHandle.java b/server/src/main/java/org/apache/iotdb/db/mpp/buffer/SinkHandle.java
index 5d9cfc8263..5f734747b5 100644
--- a/server/src/main/java/org/apache/iotdb/db/mpp/buffer/SinkHandle.java
+++ b/server/src/main/java/org/apache/iotdb/db/mpp/buffer/SinkHandle.java
@@ -198,7 +198,8 @@ public class SinkHandle implements ISinkHandle {
     }
     synchronized (this) {
       closed = true;
-      noMoreTsBlocks = true;
+      // synchronized is reentrant lock, wo we can invoke setNoMoreTsBlocks() here.
+      setNoMoreTsBlocks();
     }
     sinkHandleListener.onClosed(this);
     logger.info("Sink handle {} is closed.", this);
@@ -227,6 +228,14 @@ public class SinkHandle implements ISinkHandle {
   @Override
   public synchronized void setNoMoreTsBlocks() {
     noMoreTsBlocks = true;
+    // In current implementation, the onFinish() is only invoked when receiving the
+    // acknowledge event from SourceHandle. If the acknowledge event happens before
+    // the close(), the onFinish() won't be invoked and the instance's status will
+    // always be FLUSHING. We cannot ensure the sequence of `acknowledge event` and
+    // `close` so we need to do following check every time `noMoreTsBlocks` is updated.
+    if (isFinished()) {
+      sinkHandleListener.onFinish(this);
+    }
   }
 
   @Override