You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by xi...@apache.org on 2022/09/27 10:24:31 UTC

[iotdb] branch xingtanzjr/fix_snapshot_taker created (now 2496f0932e)

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

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


      at 2496f0932e fix the issue that taking snapshot may stuck when waiting for flush

This branch includes the following new commits:

     new 2496f0932e fix the issue that taking snapshot may stuck when waiting for flush

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 the issue that taking snapshot may stuck when waiting for flush

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

xingtanzjr pushed a commit to branch xingtanzjr/fix_snapshot_taker
in repository https://gitbox.apache.org/repos/asf/iotdb.git

commit 2496f0932e08ed280d93ddc917943828f627d784
Author: Jinrui.Zhang <xi...@gmail.com>
AuthorDate: Tue Sep 27 18:24:18 2022 +0800

    fix the issue that taking snapshot may stuck when waiting for flush
---
 .../apache/iotdb/db/engine/snapshot/SnapshotTaker.java   | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/server/src/main/java/org/apache/iotdb/db/engine/snapshot/SnapshotTaker.java b/server/src/main/java/org/apache/iotdb/db/engine/snapshot/SnapshotTaker.java
index 4b1f98aa4e..46bb086ff5 100644
--- a/server/src/main/java/org/apache/iotdb/db/engine/snapshot/SnapshotTaker.java
+++ b/server/src/main/java/org/apache/iotdb/db/engine/snapshot/SnapshotTaker.java
@@ -68,17 +68,21 @@ public class SnapshotTaker {
       throw new IOException(String.format("Failed to create directory %s", snapshotDir));
     }
 
-    if (flushBeforeSnapshot) {
-      dataRegion.syncCloseAllWorkingTsFileProcessors();
-    }
-
     File snapshotLog = new File(snapshotDir, SnapshotLogger.SNAPSHOT_LOG_NAME);
     try {
       snapshotLogger = new SnapshotLogger(snapshotLog);
-      boolean success = true;
+      boolean success;
 
-      readLockTheFile();
       try {
+        readLockTheFile();
+        if (flushBeforeSnapshot) {
+          try {
+            dataRegion.writeLock("snapshotTaker");
+            dataRegion.syncCloseAllWorkingTsFileProcessors();
+          } finally {
+            dataRegion.writeUnlock();
+          }
+        }
         success = createSnapshot(seqFiles, snapshotDir.getName());
         success = createSnapshot(unseqFiles, snapshotDir.getName()) && success;
       } finally {