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

yiguolei pushed a commit to branch branch-2.1
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/branch-2.1 by this push:
     new 0e13ee3db64 branch-2.1: [fix](restore) Release snapshots after the 
FINISHED state is persisted #47277 (#47286)
0e13ee3db64 is described below

commit 0e13ee3db64e8e7c3b4c06642223a87a627ba2a0
Author: github-actions[bot] 
<41898282+github-actions[bot]@users.noreply.github.com>
AuthorDate: Sat Jan 25 11:53:48 2025 +0800

    branch-2.1: [fix](restore) Release snapshots after the FINISHED state is 
persisted #47277 (#47286)
    
    Cherry-picked from #47277
    
    Co-authored-by: walter <maoch...@selectdb.com>
---
 .../main/java/org/apache/doris/backup/RestoreJob.java  | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)

diff --git a/fe/fe-core/src/main/java/org/apache/doris/backup/RestoreJob.java 
b/fe/fe-core/src/main/java/org/apache/doris/backup/RestoreJob.java
index fe0a2438e83..2e7ca149226 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/backup/RestoreJob.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/backup/RestoreJob.java
@@ -2067,8 +2067,8 @@ public class RestoreJob extends AbstractJob {
             restoredTbls.clear();
             restoredResources.clear();
 
-            // release snapshot before clearing snapshotInfos
-            releaseSnapshots();
+            com.google.common.collect.Table<Long, Long, SnapshotInfo> 
savedSnapshotInfos = snapshotInfos;
+            snapshotInfos = HashBasedTable.create();
 
             snapshotInfos.clear();
             fileMapping.clear();
@@ -2078,6 +2078,9 @@ public class RestoreJob extends AbstractJob {
             state = RestoreJobState.FINISHED;
 
             env.getEditLog().logRestoreJob(this);
+
+            // Only send release snapshot tasks after the job is finished.
+            releaseSnapshots(savedSnapshotInfos);
         }
 
         LOG.info("job is finished. is replay: {}. {}", isReplay, this);
@@ -2145,7 +2148,7 @@ public class RestoreJob extends AbstractJob {
         }
     }
 
-    private void releaseSnapshots() {
+    private void releaseSnapshots(com.google.common.collect.Table<Long, Long, 
SnapshotInfo> snapshotInfos) {
         if (snapshotInfos.isEmpty()) {
             return;
         }
@@ -2339,9 +2342,8 @@ public class RestoreJob extends AbstractJob {
             // backupMeta is useless
             backupMeta = null;
 
-            releaseSnapshots();
-
-            snapshotInfos.clear();
+            com.google.common.collect.Table<Long, Long, SnapshotInfo> 
savedSnapshotInfos = snapshotInfos;
+            snapshotInfos = HashBasedTable.create();
             fileMapping.clear();
             jobInfo.releaseSnapshotInfo();
 
@@ -2353,6 +2355,10 @@ public class RestoreJob extends AbstractJob {
 
             LOG.info("finished to cancel restore job. current state: {}. is 
replay: {}. {}",
                      curState.name(), isReplay, this);
+
+            // Send release snapshot tasks after log restore job, so that the 
snapshot won't be released
+            // before the cancelled restore job is persisted.
+            releaseSnapshots(savedSnapshotInfos);
             return;
         }
 


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org

Reply via email to