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

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


The following commit(s) were added to refs/heads/branch-2.0 by this push:
     new 9f73b201fd3 [fix](backup) save finished state for local repo backup 
(#36014)
9f73b201fd3 is described below

commit 9f73b201fd393d8f73c8019e71275ab89c7255b8
Author: walter <w41te...@gmail.com>
AuthorDate: Fri Jun 7 14:05:24 2024 +0800

    [fix](backup) save finished state for local repo backup (#36014)
    
    Cherry-pick #35491
    
    The backup finished state in the local repo is not logged. So if there
    exist multiple local repo backups, and FE was restarted, then these
    backup records will be reset to the UPLOAD_INFO state.
---
 .../org/apache/doris/backup/BackupHandler.java     |  1 +
 .../java/org/apache/doris/backup/BackupJob.java    | 35 ++++++++++++----------
 .../java/org/apache/doris/persist/EditLog.java     | 10 ++++---
 3 files changed, 27 insertions(+), 19 deletions(-)

diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/backup/BackupHandler.java 
b/fe/fe-core/src/main/java/org/apache/doris/backup/BackupHandler.java
index c682262de02..4abcc4e7217 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/backup/BackupHandler.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/backup/BackupHandler.java
@@ -706,6 +706,7 @@ public class BackupHandler extends MasterDaemon implements 
Writable {
             // We use replayed job, not the existing job, to do the 
replayRun().
             // Because if we use the existing job to run again,
             // for example: In restore job, PENDING will transfer to 
SNAPSHOTING, not DOWNLOAD.
+            job.setEnv(env);
             job.replayRun();
         }
 
diff --git a/fe/fe-core/src/main/java/org/apache/doris/backup/BackupJob.java 
b/fe/fe-core/src/main/java/org/apache/doris/backup/BackupJob.java
index f1fd703041b..b6f031ab7d4 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/backup/BackupJob.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/backup/BackupJob.java
@@ -254,8 +254,11 @@ public class BackupJob extends AbstractJob {
 
     @Override
     public synchronized void replayRun() {
-        // Backup process does not change any current catalog state,
-        // So nothing need to be done when replaying log
+        LOG.info("replay run backup job: {}", this);
+        if (state == BackupJobState.FINISHED && repoId == 
Repository.KEEP_ON_LOCAL_REPO_ID) {
+            Snapshot snapshot = new Snapshot(label, metaInfoBytes, 
jobInfoBytes);
+            env.getBackupHandler().addSnapshot(label, snapshot);
+        }
     }
 
     @Override
@@ -760,22 +763,18 @@ public class BackupJob extends AbstractJob {
     }
 
     private void uploadMetaAndJobInfoFile() {
-        if (repoId == Repository.KEEP_ON_LOCAL_REPO_ID) {
-            state = BackupJobState.FINISHED;
-            Snapshot snapshot = new Snapshot(label, metaInfoBytes, 
jobInfoBytes);
-            env.getBackupHandler().addSnapshot(label, snapshot);
-            return;
-        }
+        if (repoId != Repository.KEEP_ON_LOCAL_REPO_ID) {
+            String remoteMetaInfoFile = repo.assembleMetaInfoFilePath(label);
+            if (!uploadFile(localMetaInfoFilePath, remoteMetaInfoFile)) {
+                return;
+            }
 
-        String remoteMetaInfoFile = repo.assembleMetaInfoFilePath(label);
-        if (!uploadFile(localMetaInfoFilePath, remoteMetaInfoFile)) {
-            return;
+            String remoteJobInfoFile = repo.assembleJobInfoFilePath(label, 
createTime);
+            if (!uploadFile(localJobInfoFilePath, remoteJobInfoFile)) {
+                return;
+            }
         }
 
-        String remoteJobInfoFile = repo.assembleJobInfoFilePath(label, 
createTime);
-        if (!uploadFile(localJobInfoFilePath, remoteJobInfoFile)) {
-            return;
-        }
 
         finishedTime = System.currentTimeMillis();
         state = BackupJobState.FINISHED;
@@ -783,6 +782,12 @@ public class BackupJob extends AbstractJob {
         // log
         env.getEditLog().logBackupJob(this);
         LOG.info("job is finished. {}", this);
+
+        if (repoId == Repository.KEEP_ON_LOCAL_REPO_ID) {
+            Snapshot snapshot = new Snapshot(label, metaInfoBytes, 
jobInfoBytes);
+            env.getBackupHandler().addSnapshot(label, snapshot);
+            return;
+        }
     }
 
     private boolean uploadFile(String localFilePath, String remoteFilePath) {
diff --git a/fe/fe-core/src/main/java/org/apache/doris/persist/EditLog.java 
b/fe/fe-core/src/main/java/org/apache/doris/persist/EditLog.java
index ea2e42b084e..79dde3e5874 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/persist/EditLog.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/persist/EditLog.java
@@ -160,7 +160,9 @@ public class EditLog {
     public static void loadJournal(Env env, Long logId, JournalEntity journal) 
{
         short opCode = journal.getOpCode();
         if (opCode != OperationType.OP_SAVE_NEXTID && opCode != 
OperationType.OP_TIMESTAMP) {
-            LOG.debug("replay journal op code: {}", opCode);
+            if (LOG.isDebugEnabled()) {
+                LOG.debug("replay journal op code: {}, log id: {}", opCode, 
logId);
+            }
         }
         try {
             switch (opCode) {
@@ -1090,7 +1092,7 @@ public class EditLog {
                 }
                 default: {
                     IOException e = new IOException();
-                    LOG.error("UNKNOWN Operation Type {}", opCode, e);
+                    LOG.error("UNKNOWN Operation Type {}, log id: {}", opCode, 
logId, e);
                     throw e;
                 }
             }
@@ -1114,9 +1116,9 @@ public class EditLog {
              * log a warning here to debug when happens. This could happen to 
other meta
              * like DB.
              */
-            LOG.warn("[INCONSISTENT META] replay failed {}: {}", journal, 
e.getMessage(), e);
+            LOG.warn("[INCONSISTENT META] replay log {} failed, journal {}: 
{}", logId, journal, e.getMessage(), e);
         } catch (Exception e) {
-            LOG.error("Operation Type {}", opCode, e);
+            LOG.error("replay Operation Type {}, log id: {}", opCode, logId, 
e);
             System.exit(-1);
         }
     }


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

Reply via email to