morningman closed pull request #460: Optimize backup & restore process
URL: https://github.com/apache/incubator-doris/pull/460
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/be/src/agent/task_worker_pool.cpp 
b/be/src/agent/task_worker_pool.cpp
index 6d933378..6462b62e 100644
--- a/be/src/agent/task_worker_pool.cpp
+++ b/be/src/agent/task_worker_pool.cpp
@@ -1826,7 +1826,7 @@ void* 
TaskWorkerPool::_report_olap_table_worker_thread_callback(void* arg_this)
 }
 
 void* TaskWorkerPool::_upload_worker_thread_callback(void* arg_this) {
-    TaskWorkerPool* worker_pool_this = (TaskWorkerPool*)arg_this;
+    TaskWorkerPool* worker_pool_this = (TaskWorkerPool*) arg_this;
 
 #ifndef BE_TEST
     while (true) {
@@ -1848,12 +1848,11 @@ void* 
TaskWorkerPool::_upload_worker_thread_callback(void* arg_this) {
                   << ", job id:" << upload_request.job_id;
 
         std::map<int64_t, std::vector<std::string>> tablet_files;
-        SnapshotLoader* loader = worker_pool_this->_env->snapshot_loader();
-        Status status = loader->upload(
+        SnapshotLoader loader(worker_pool_this->_env, upload_request.job_id, 
agent_task_req.signature);
+        Status status = loader.upload(
                 upload_request.src_dest_map,
                 upload_request.broker_addr,
                 upload_request.broker_prop,
-                upload_request.job_id,
                 &tablet_files);
 
         TStatusCode::type status_code = TStatusCode::OK; 
@@ -1917,12 +1916,11 @@ void* 
TaskWorkerPool::_download_worker_thread_callback(void* arg_this) {
 
         // TODO: download
         std::vector<int64_t> downloaded_tablet_ids;
-        SnapshotLoader* loader = worker_pool_this->_env->snapshot_loader();
-        Status status = loader->download(
+        SnapshotLoader loader(worker_pool_this->_env, download_request.job_id, 
agent_task_req.signature);
+        Status status = loader.download(
                 download_request.src_dest_map,
                 download_request.broker_addr,
                 download_request.broker_prop,
-                download_request.job_id,
                 &downloaded_tablet_ids);
 
         if (!status.ok()) {
@@ -2217,8 +2215,8 @@ AgentStatus TaskWorkerPool::_move_dir(
     std::string dest_tablet_dir = tablet->construct_dir_path();
     std::string store_path = tablet->store()->path();
 
-    SnapshotLoader* loader = _env->snapshot_loader();
-    Status status = loader->move(src, dest_tablet_dir, store_path, job_id, 
overwrite);
+    SnapshotLoader loader(_env, job_id, tablet_id);
+    Status status = loader.move(src, dest_tablet_dir, store_path, overwrite);
 
     if (!status.ok()) {
         OLAP_LOG_WARNING("move failed. job id: %ld, msg: %s",
diff --git a/be/src/common/config.h b/be/src/common/config.h
index 0c9272d7..7d94f17d 100644
--- a/be/src/common/config.h
+++ b/be/src/common/config.h
@@ -81,9 +81,9 @@ namespace config {
     // the count of thread to check consistency
     CONF_Int32(check_consistency_worker_count, "1");
     // the count of thread to upload
-    CONF_Int32(upload_worker_count, "3");
+    CONF_Int32(upload_worker_count, "1");
     // the count of thread to download
-    CONF_Int32(download_worker_count, "3");
+    CONF_Int32(download_worker_count, "1");
     // the count of thread to make snapshot
     CONF_Int32(make_snapshot_worker_count, "5");
     // the count of thread to release snapshot
diff --git a/be/src/runtime/exec_env.h b/be/src/runtime/exec_env.h
index 9d295512..c1d929e7 100644
--- a/be/src/runtime/exec_env.h
+++ b/be/src/runtime/exec_env.h
@@ -43,7 +43,6 @@ class PriorityThreadPool;
 class PullLoadTaskMgr;
 class ReservationTracker;
 class ResultBufferMgr;
-class SnapshotLoader;
 class TMasterInfo;
 class TabletWriterMgr;
 class TestExecEnv;
@@ -104,7 +103,6 @@ class ExecEnv {
     BfdParser* bfd_parser() const { return _bfd_parser; }
     PullLoadTaskMgr* pull_load_task_mgr() const { return _pull_load_task_mgr; }
     BrokerMgr* broker_mgr() const { return _broker_mgr; }
-    SnapshotLoader* snapshot_loader() const { return _snapshot_loader; }
     BrpcStubCache* brpc_stub_cache() const { return _brpc_stub_cache; }
     ReservationTracker* buffer_reservation() { return _buffer_reservation; }
     BufferPool* buffer_pool() { return _buffer_pool; }
@@ -151,7 +149,6 @@ class ExecEnv {
     BrokerMgr* _broker_mgr = nullptr;
     TabletWriterMgr* _tablet_writer_mgr = nullptr;
     LoadStreamMgr* _load_stream_mgr = nullptr;
-    SnapshotLoader* _snapshot_loader = nullptr;
     BrpcStubCache* _brpc_stub_cache = nullptr;
 
     ReservationTracker* _buffer_reservation = nullptr;
diff --git a/be/src/runtime/exec_env_init.cpp b/be/src/runtime/exec_env_init.cpp
index 1584567e..896356f2 100644
--- a/be/src/runtime/exec_env_init.cpp
+++ b/be/src/runtime/exec_env_init.cpp
@@ -45,7 +45,6 @@
 #include "runtime/load_path_mgr.h"
 #include "runtime/load_stream_mgr.h"
 #include "runtime/pull_load_task_mgr.h"
-#include "runtime/snapshot_loader.h"
 #include "util/pretty_printer.h"
 #include "util/doris_metrics.h"
 #include "util/brpc_stub_cache.h"
@@ -93,7 +92,6 @@ Status ExecEnv::_init(const std::vector<StorePath>& 
store_paths) {
     _broker_mgr = new BrokerMgr(this);
     _tablet_writer_mgr = new TabletWriterMgr(this);
     _load_stream_mgr = new LoadStreamMgr();
-    _snapshot_loader = new SnapshotLoader(this);
     _brpc_stub_cache = new BrpcStubCache();
 
     _client_cache->init_metrics(DorisMetrics::metrics(), "backend");
@@ -182,7 +180,6 @@ void ExecEnv::_init_buffer_pool(int64_t min_page_size,
 
 void ExecEnv::_destory() {
     delete _brpc_stub_cache;
-    delete _snapshot_loader;
     delete _load_stream_mgr;
     delete _tablet_writer_mgr;
     delete _broker_mgr;
diff --git a/be/src/runtime/runtime_state.cpp b/be/src/runtime/runtime_state.cpp
index a21ecf34..ac5ca6db 100644
--- a/be/src/runtime/runtime_state.cpp
+++ b/be/src/runtime/runtime_state.cpp
@@ -46,6 +46,7 @@
 
 namespace doris {
 
+// for ut only
 RuntimeState::RuntimeState(
         const TUniqueId& fragment_instance_id,
         const TQueryOptions& query_options,
diff --git a/be/src/runtime/runtime_state.h b/be/src/runtime/runtime_state.h
index f8d46ee5..b58ef954 100644
--- a/be/src/runtime/runtime_state.h
+++ b/be/src/runtime/runtime_state.h
@@ -65,11 +65,10 @@ class RowDescriptor;
 // query and shared across all execution nodes of that query.
 class RuntimeState {
 public:
-    // NOTE: only used to unit test
-    RuntimeState(
-        const TUniqueId& fragment_instance_id,
-        const TQueryOptions& query_options,
-        const std::string& now, ExecEnv* exec_env);
+    // for ut only
+    RuntimeState(const TUniqueId& fragment_instance_id,
+                 const TQueryOptions& query_options,
+                 const std::string& now, ExecEnv* exec_env);
 
     RuntimeState(
         const TExecPlanFragmentParams& fragment_params,
diff --git a/be/src/runtime/snapshot_loader.cpp 
b/be/src/runtime/snapshot_loader.cpp
index 4b51babd..58426928 100644
--- a/be/src/runtime/snapshot_loader.cpp
+++ b/be/src/runtime/snapshot_loader.cpp
@@ -21,10 +21,14 @@
 
 #include "gen_cpp/PaloBrokerService_types.h"
 #include "gen_cpp/TPaloBrokerService.h"
+#include "gen_cpp/FrontendService.h"
+#include "gen_cpp/FrontendService_types.h"
+#include "gen_cpp/HeartbeatService_types.h"
 
 #include "common/logging.h"
 #include "exec/broker_reader.h"
 #include "exec/broker_writer.h"
+#include "exec/schema_scanner/frontend_helper.h"
 #include "olap/file_helper.h"
 #include "olap/olap_engine.h"
 #include "olap/olap_table.h"
@@ -54,8 +58,13 @@ inline const std::string& client_id(ExecEnv* env, const 
TNetworkAddress& addr) {
 }
 #endif
 
-SnapshotLoader::SnapshotLoader(ExecEnv* env) :
-    _env(env) {
+SnapshotLoader::SnapshotLoader(
+        ExecEnv* env,
+        int64_t job_id,
+        int64_t task_id) :
+    _env(env),
+    _job_id(job_id),
+    _task_id(task_id) {
 
 }
 
@@ -67,12 +76,17 @@ Status SnapshotLoader::upload(
         const std::map<std::string, std::string>& src_to_dest_path,
         const TNetworkAddress& broker_addr,
         const std::map<std::string, std::string>& broker_prop,
-        int64_t job_id,
         std::map<int64_t, std::vector<std::string>>* tablet_files) {
 
     LOG(INFO) << "begin to upload snapshot files. num: "
               << src_to_dest_path.size() << ", broker addr: "
-              << broker_addr << ", job: " << job_id;
+              << broker_addr << ", job: " << _job_id
+              << ", task" << _task_id;
+
+    // check if job has already been cancelled
+    int tmp_counter = 1;
+    RETURN_IF_ERROR(_report_every(0, &tmp_counter, 0, 0,
+            TTaskType::type::UPLOAD));
 
     Status status = Status::OK;
     // 1. validate local tablet snapshot paths
@@ -92,6 +106,11 @@ Status SnapshotLoader::upload(
     std::vector<TNetworkAddress> broker_addrs;
     broker_addrs.push_back(broker_addr);
     // 3. for each src path, upload it to remote storage
+    // we report to frontend for every 10 files, and we will cancel the job if
+    // the job has already been cancelled in frontend.
+    int report_counter = 0;
+    int total_num = src_to_dest_path.size();
+    int finished_num = 0;
     for (auto iter = src_to_dest_path.begin(); iter != src_to_dest_path.end();
             iter++) {
         const std::string& src_path = iter->first;
@@ -118,6 +137,10 @@ Status SnapshotLoader::upload(
 
         // 2.3 iterate local files
         for (auto it = local_files.begin(); it != local_files.end(); it++) {
+
+            RETURN_IF_ERROR(_report_every(10, &report_counter, finished_num, 
total_num,
+                TTaskType::type::UPLOAD));
+
             const std::string& local_file = *it;
             // calc md5sum of localfile
             std::string md5sum;
@@ -210,11 +233,13 @@ Status SnapshotLoader::upload(
         } // end for each tablet's local files
 
         tablet_files->emplace(tablet_id, local_files_with_checksum);
+        finished_num++;
         LOG(INFO) << "finished to write tablet to remote. local path: "
                 << src_path << ", remote path: " << dest_path;
     } // end for each tablet path
 
-    LOG(INFO) << "finished to upload snapshots. job: " << job_id;
+    LOG(INFO) << "finished to upload snapshots. job: " << _job_id
+            << ", task id: " << _task_id;
     return status;
 }
 
@@ -227,12 +252,17 @@ Status SnapshotLoader::download(
         const std::map<std::string, std::string>& src_to_dest_path,
         const TNetworkAddress& broker_addr,
         const std::map<std::string, std::string>& broker_prop,
-        int64_t job_id,
         std::vector<int64_t>* downloaded_tablet_ids) {
 
     LOG(INFO) << "begin to download snapshot files. num: "
               << src_to_dest_path.size() << ", broker addr: "
-              << broker_addr << ", job: " << job_id;
+              << broker_addr << ", job: " << _job_id
+              << ", task id: " << _task_id;
+
+    // check if job has already been cancelled
+    int tmp_counter = 1;
+    RETURN_IF_ERROR(_report_every(0, &tmp_counter, 0, 0,
+            TTaskType::type::DOWNLOAD));
 
     Status status = Status::OK;
     // 1. validate local tablet snapshot paths
@@ -252,6 +282,9 @@ Status SnapshotLoader::download(
     std::vector<TNetworkAddress> broker_addrs;
     broker_addrs.push_back(broker_addr);
     // 3. for each src path, download it to local storage
+    int report_counter = 0;
+    int total_num = src_to_dest_path.size();
+    int finished_num = 0;
     for (auto iter = src_to_dest_path.begin(); iter != src_to_dest_path.end();
             iter++) {
         const std::string& remote_path = iter->first;
@@ -285,6 +318,10 @@ Status SnapshotLoader::download(
         }
 
         for (auto& iter : remote_files) {
+
+            RETURN_IF_ERROR(_report_every(10, &report_counter, finished_num, 
total_num,
+                    TTaskType::type::DOWNLOAD));
+
             bool need_download = false;
             const std::string& remote_file = iter.first;
             const FileStat& file_stat = iter.second;
@@ -434,9 +471,12 @@ Status SnapshotLoader::download(
                         << ", ignore it";
             }
         }
+
+        finished_num++;
     } // end for src_to_dest_path
 
-    LOG(INFO) << "finished to download snapshots. job: " << job_id;
+    LOG(INFO) << "finished to download snapshots. job: " << _job_id
+            << ", task id: " << _task_id;
     return status;
 }
 
@@ -449,12 +489,12 @@ Status SnapshotLoader::move(
     const std::string& snapshot_path,
     const std::string& tablet_path,
     const std::string& store_path,
-    int64_t job_id,
     bool overwrite) {
 
     LOG(INFO) << "begin to move snapshot files. from: "
               << snapshot_path << ", to: " << tablet_path
-              << ", store: " << store_path << ", job: " << job_id;
+              << ", store: " << store_path << ", job: " << _job_id
+              << ", task id: " << _task_id;
 
     Status status = Status::OK;
 
@@ -943,4 +983,56 @@ Status SnapshotLoader::_get_tablet_id_from_remote_path(
     return Status::OK;
 }
 
+// only return CANCELLED if FE return that job is cancelled.
+// otherwise, return OK
+Status SnapshotLoader::_report_every(
+        int report_threshold,
+        int* counter,
+        int32_t finished_num,
+        int32_t total_num,
+        TTaskType::type type) {
+
+    ++*counter;
+    if (*counter <= report_threshold) {
+        return Status::OK;
+    }
+
+    LOG(INFO) << "report to frontend. job id: " << _job_id
+            << ", task id: " << _task_id
+            << ", finished num: " << finished_num
+            << ", total num:" << total_num;
+
+    TNetworkAddress master_addr = _env->master_info()->network_address;
+
+    TSnapshotLoaderReportRequest request;
+    request.job_id = _job_id;
+    request.task_id = _task_id;
+    request.task_type = type;
+    request.__set_finished_num(finished_num);
+    request.__set_total_num(total_num);
+    TStatus report_st;
+
+    Status rpcStatus = FrontendHelper::rpc(
+        master_addr.hostname, master_addr.port,
+        [&request, &report_st] (FrontendServiceConnection& client) {
+            client->snapshotLoaderReport(report_st, request);
+        }, 10000);
+
+    if (!rpcStatus.ok()) {
+        // rpc failed, ignore
+        return Status::OK;
+    }
+
+    // reset
+    *counter = 0;
+    if (report_st.status_code == TStatusCode::CANCELLED) {
+        LOG(INFO) << "job is cancelled. job id: " << _job_id
+                << ", task id: " << _task_id;
+        return Status::CANCELLED;
+    }
+    return Status::OK;
+}
+
+
+
 } // end namespace doris
diff --git a/be/src/runtime/snapshot_loader.h b/be/src/runtime/snapshot_loader.h
index 9eca9670..e9aea53c 100644
--- a/be/src/runtime/snapshot_loader.h
+++ b/be/src/runtime/snapshot_loader.h
@@ -61,7 +61,7 @@ struct FileStat {
  */
 class SnapshotLoader {
 public:
-    SnapshotLoader(ExecEnv* env);
+    SnapshotLoader(ExecEnv* env, int64_t job_id, int64_t task_id);
 
     ~SnapshotLoader();
 
@@ -69,21 +69,18 @@ class SnapshotLoader {
         const std::map<std::string, std::string>& src_to_dest_path,
         const TNetworkAddress& broker_addr,
         const std::map<std::string, std::string>& broker_prop,
-        int64_t job_id,
         std::map<int64_t, std::vector<std::string>>* tablet_files);
 
     Status download(
         const std::map<std::string, std::string>& src_to_dest_path,
         const TNetworkAddress& broker_addr,
         const std::map<std::string, std::string>& broker_prop,
-        int64_t job_id,
         std::vector<int64_t>* downloaded_tablet_ids);
 
     Status move(
         const std::string& snapshot_path,
         const std::string& tablet_path,
         const std::string& store_path,
-        int64_t job_id,
         bool overwrite);
 
 private:
@@ -133,8 +130,15 @@ class SnapshotLoader {
         const std::string& remote_path,
         int64_t* tablet_id);
 
+    Status _report_every(
+        int report_threshold, int* counter,
+        int finished_num, int total_num,
+        TTaskType::type type);
+
 private:
     ExecEnv* _env;
+    int64_t _job_id;
+    int64_t _task_id;
 };
 
 } // end namespace doris
diff --git a/be/test/runtime/snapshot_loader_test.cpp 
b/be/test/runtime/snapshot_loader_test.cpp
index f78f0fc8..4e63275e 100644
--- a/be/test/runtime/snapshot_loader_test.cpp
+++ b/be/test/runtime/snapshot_loader_test.cpp
@@ -37,7 +37,7 @@ class SnapshotLoaderTest : public testing::Test {
 };
 
 TEST_F(SnapshotLoaderTest, NormalCase) {
-    SnapshotLoader loader(_exec_env);
+    SnapshotLoader loader(_exec_env, 1L, 2L);
 
     ASSERT_TRUE(loader._end_with("abt.dat", ".dat"));
     ASSERT_FALSE(loader._end_with("abt.dat", ".da"));
diff --git a/docs/help/Contents/Data Definition/ddl_stmt.md 
b/docs/help/Contents/Data Definition/ddl_stmt.md
index 790b11eb..18d0e08a 100644
--- a/docs/help/Contents/Data Definition/ddl_stmt.md    
+++ b/docs/help/Contents/Data Definition/ddl_stmt.md    
@@ -752,7 +752,7 @@
 ## example
     1. 创建名为 bos_repo 的仓库,依赖 BOS broker "bos_broker",数据根目录为:bos://palo_backup
         CREATE REPOSITORY `bos_repo`
-        WITH BROKER `bos_broker `
+        WITH BROKER `bos_broker`
         ON LOCATION "bos://palo_backup"
         PROPERTIES
         (
@@ -763,7 +763,7 @@
      
     2. 创建和示例 1 相同的仓库,但属性为只读:
         CREATE READ ONLY REPOSITORY `bos_repo`
-        WITH BROKER `bos_broker `
+        WITH BROKER `bos_broker`
         ON LOCATION "bos://palo_backup"
         PROPERTIES
         (
@@ -774,7 +774,7 @@
 
     3. 创建名为 hdfs_repo 的仓库,依赖 Baidu hdfs broker 
"hdfs_broker",数据根目录为:hdfs://hadoop-name-node:54310/path/to/repo/
         CREATE REPOSITORY `hdfs_repo`
-        WITH BROKER `hdfs_broker `
+        WITH BROKER `hdfs_broker`
         ON LOCATION "hdfs://hadoop-name-node:54310/path/to/repo/"
         PROPERTIES
         (
@@ -867,7 +867,7 @@
 
 ## example
     1. 从 example_repo 中恢复备份 snapshot_1 中的表 backup_tbl 到数据库 example_db1,时间版本为 
"2018-05-04-16-45-08"。恢复为 1 个副本:
-        RESTORE SNAPSHOT example_db1.`snapshot_1 `
+        RESTORE SNAPSHOT example_db1.`snapshot_1`
         FROM `example_repo`
         ON ( `backup_tbl` )
         PROPERTIES
@@ -877,8 +877,8 @@
         );
         
     2. 从 example_repo 中恢复备份 snapshot_2 中的表 backup_tbl 的分区 p1,p2,以及表 
backup_tbl2 到数据库 example_db1,并重命名为 new_tbl,时间版本为 "2018-05-04-17-11-01"。默认恢复为 3 
个副本:
-        RESTORE SNAPSHOT example_db1.`snapshot_2 `
-        FROM `example_repo `
+        RESTORE SNAPSHOT example_db1.`snapshot_2`
+        FROM `example_repo`
         ON
         (
             `backup_tbl` PARTITION (`p1`, `p2`) AS `backup_tbl2`,
diff --git a/fe/src/main/java/org/apache/doris/analysis/ShowBackupStmt.java 
b/fe/src/main/java/org/apache/doris/analysis/ShowBackupStmt.java
index 34dce9cd..e9c2e9e8 100644
--- a/fe/src/main/java/org/apache/doris/analysis/ShowBackupStmt.java
+++ b/fe/src/main/java/org/apache/doris/analysis/ShowBackupStmt.java
@@ -35,7 +35,7 @@
     public static final ImmutableList<String> TITLE_NAMES = new 
ImmutableList.Builder<String>()
             
.add("JobId").add("SnapshotName").add("DbName").add("State").add("BackupObjs").add("CreateTime")
             
.add("SnapshotFinishedTime").add("UploadFinishedTime").add("FinishedTime").add("UnfinishedTasks")
-            .add("TaskErrMsg").add("Status").add("Timeout")
+            .add("Progress").add("TaskErrMsg").add("Status").add("Timeout")
             .build();
 
     private String dbName;
@@ -90,4 +90,9 @@ public String toSql() {
     public String toString() {
         return toSql();
     }
+
+    @Override
+    public RedirectStatus getRedirectStatus() {
+        return RedirectStatus.FORWARD_NO_SYNC;
+    }
 }
diff --git a/fe/src/main/java/org/apache/doris/analysis/ShowRestoreStmt.java 
b/fe/src/main/java/org/apache/doris/analysis/ShowRestoreStmt.java
index fb8881aa..a378ef2a 100644
--- a/fe/src/main/java/org/apache/doris/analysis/ShowRestoreStmt.java
+++ b/fe/src/main/java/org/apache/doris/analysis/ShowRestoreStmt.java
@@ -36,8 +36,8 @@
             
.add("JobId").add("Label").add("Timestamp").add("DbName").add("State")
             .add("AllowLoad").add("ReplicationNum")
             
.add("RestoreObjs").add("CreateTime").add("MetaPreparedTime").add("SnapshotFinishedTime")
-            
.add("DownloadFinishedTime").add("FinishedTime").add("UnfinishedTasks").add("TaskErrMsg")
-            .add("Status").add("Timeout")
+            
.add("DownloadFinishedTime").add("FinishedTime").add("UnfinishedTasks").add("Progress")
+            .add("TaskErrMsg").add("Status").add("Timeout")
             .build();
 
     private String dbName;
@@ -100,5 +100,10 @@ public String toSql() {
     public String toString() {
         return toSql();
     }
+
+    @Override
+    public RedirectStatus getRedirectStatus() {
+        return RedirectStatus.FORWARD_NO_SYNC;
+    }
 }
 
diff --git a/fe/src/main/java/org/apache/doris/backup/AbstractJob.java 
b/fe/src/main/java/org/apache/doris/backup/AbstractJob.java
index d257e4fc..849ebb82 100644
--- a/fe/src/main/java/org/apache/doris/backup/AbstractJob.java
+++ b/fe/src/main/java/org/apache/doris/backup/AbstractJob.java
@@ -18,6 +18,7 @@
 package org.apache.doris.backup;
 
 import org.apache.doris.catalog.Catalog;
+import org.apache.doris.common.Pair;
 import org.apache.doris.common.io.Text;
 import org.apache.doris.common.io.Writable;
 
@@ -68,6 +69,9 @@
     protected long finishedTime = -1;
     protected long timeoutMs;
 
+    // task signature -> <finished num / total num>
+    protected Map<Long, Pair<Integer, Integer>> taskProgress = 
Maps.newConcurrentMap();
+
     protected boolean isTypeRead = false;
 
     // save err msg of tasks
diff --git a/fe/src/main/java/org/apache/doris/backup/BackupHandler.java 
b/fe/src/main/java/org/apache/doris/backup/BackupHandler.java
index 9ea24c6f..9a65da3e 100644
--- a/fe/src/main/java/org/apache/doris/backup/BackupHandler.java
+++ b/fe/src/main/java/org/apache/doris/backup/BackupHandler.java
@@ -25,6 +25,7 @@
 import org.apache.doris.analysis.DropRepositoryStmt;
 import org.apache.doris.analysis.RestoreStmt;
 import org.apache.doris.analysis.TableRef;
+import org.apache.doris.backup.AbstractJob.JobType;
 import org.apache.doris.backup.BackupJob.BackupJobState;
 import org.apache.doris.backup.BackupJobInfo.BackupTableInfo;
 import org.apache.doris.catalog.Catalog;
@@ -38,6 +39,7 @@
 import org.apache.doris.common.DdlException;
 import org.apache.doris.common.ErrorCode;
 import org.apache.doris.common.ErrorReport;
+import org.apache.doris.common.Pair;
 import org.apache.doris.common.io.Writable;
 import org.apache.doris.common.util.Daemon;
 import org.apache.doris.task.DirMoveTask;
@@ -45,6 +47,7 @@
 import org.apache.doris.task.SnapshotTask;
 import org.apache.doris.task.UploadTask;
 import org.apache.doris.thrift.TFinishTaskRequest;
+import org.apache.doris.thrift.TTaskType;
 
 import com.google.common.base.Preconditions;
 import com.google.common.collect.Lists;
@@ -525,6 +528,23 @@ public void replayAddJob(AbstractJob job) {
         dbIdToBackupOrRestoreJob.put(job.getDbId(), job);
     }
 
+    public boolean report(TTaskType type, long jobId, long taskId, int 
finishedNum, int totalNum) {
+        for (AbstractJob job : dbIdToBackupOrRestoreJob.values()) {
+            if (job.getType() == JobType.BACKUP) {
+                if (!job.isDone() && job.getJobId() == jobId && type == 
TTaskType.UPLOAD) {
+                    job.taskProgress.put(taskId, Pair.create(finishedNum, 
totalNum));
+                    return true;
+                }
+            } else if (job.getType() == JobType.RESTORE) {
+                if (!job.isDone() && job.getJobId() == jobId && type == 
TTaskType.DOWNLOAD) {
+                    job.taskProgress.put(taskId, Pair.create(finishedNum, 
totalNum));
+                    return true;
+                }
+            }
+        }
+        return false;
+    }
+
     public static BackupHandler read(DataInput in) throws IOException {
         BackupHandler backupHandler = new BackupHandler();
         backupHandler.readFields(in);
diff --git a/fe/src/main/java/org/apache/doris/backup/BackupJob.java 
b/fe/src/main/java/org/apache/doris/backup/BackupJob.java
index 49a94944..2a83f097 100644
--- a/fe/src/main/java/org/apache/doris/backup/BackupJob.java
+++ b/fe/src/main/java/org/apache/doris/backup/BackupJob.java
@@ -161,6 +161,7 @@ public synchronized boolean 
finishTabletSnapshotTask(SnapshotTask task, TFinishT
                 request.getSnapshot_files());
         
         snapshotInfos.put(task.getTabletId(), info);
+        taskProgress.remove(task.getTabletId());
         boolean res = unfinishedTaskIds.remove(task.getTabletId());
         taskErrMsg.remove(task.getTabletId());
         LOG.debug("get finished snapshot info: {}, unfinished tasks num: {}, 
remove result: {}. {}",
@@ -217,6 +218,7 @@ public synchronized boolean 
finishSnapshotUploadTask(UploadTask task, TFinishTas
             info.setFiles(tabletFileMap.get(tabletId));
         }
 
+        taskProgress.remove(task.getSignature());
         boolean res = unfinishedTaskIds.remove(task.getSignature());
         taskErrMsg.remove(task.getTabletId());
         LOG.debug("get finished upload snapshot task, unfinished tasks num: 
{}, remove result: {}. {}",
@@ -295,7 +297,10 @@ public synchronized void run() {
                 break;
         }
 
-        if (!status.ok()) {
+        // we don't want to cancel the job if we already in state UPLOAD_INFO,
+        // which is the final step of backup job. just retry it.
+        // if it encounters some unrecoverable errors, just retry it until 
timeout.
+        if (!status.ok() && state != BackupJobState.UPLOAD_INFO) {
             cancelInternal();
         }
     }
@@ -360,6 +365,7 @@ private void prepareAndSendSnapshotTask() {
             }
 
             unfinishedTaskIds.clear();
+            taskProgress.clear();
             taskErrMsg.clear();
             // create snapshot tasks
             for (TableRef tblRef : tableRefs) {
@@ -454,6 +460,7 @@ private void waitingAllSnapshotsFinished() {
     private void uploadSnapshot() {
         // reuse this set to save all unfinished tablets
         unfinishedTaskIds.clear();
+        taskProgress.clear();
         taskErrMsg.clear();
 
         // We classify the snapshot info by backend
@@ -698,9 +705,11 @@ private void cancelInternal() {
         info.add(TimeUtils.longToTimeString(snapshopUploadFinishedTime));
         info.add(TimeUtils.longToTimeString(finishedTime));
         info.add(Joiner.on(", ").join(unfinishedTaskIds));
-        List<String> msgs = taskErrMsg.entrySet().stream().map(n -> "[" + 
n.getKey() + ": " + n.getValue()
-                + "]").collect(Collectors.toList());
-        info.add(Joiner.on(", ").join(msgs));
+        info.add(Joiner.on(", ").join(taskProgress.entrySet().stream().map(
+                e -> "[" + e.getKey() + ": " + e.getValue().first + "/" + 
e.getValue().second + "]").collect(
+                        Collectors.toList())));
+        info.add(Joiner.on(", ").join(taskErrMsg.entrySet().stream().map(n -> 
"[" + n.getKey() + ": " + n.getValue()
+                + "]").collect(Collectors.toList())));
         info.add(status.toString());
         info.add(String.valueOf(timeoutMs / 1000));
         return info;
diff --git a/fe/src/main/java/org/apache/doris/backup/BackupJobInfo.java 
b/fe/src/main/java/org/apache/doris/backup/BackupJobInfo.java
index 16e76a15..c788659e 100644
--- a/fe/src/main/java/org/apache/doris/backup/BackupJobInfo.java
+++ b/fe/src/main/java/org/apache/doris/backup/BackupJobInfo.java
@@ -408,18 +408,25 @@ private static void genFromJson(String json, 
BackupJobInfo jobInfo) {
     public void writeToFile(File jobInfoFile) throws FileNotFoundException {
         PrintWriter printWriter = new PrintWriter(jobInfoFile);
         try {
-            printWriter.print(toJson().toString());
+            printWriter.print(toJson(true).toString());
             printWriter.flush();
         } finally {
             printWriter.close();
         }
     }
 
-    public JSONObject toJson() {
+    // Only return basic info, table and partitions
+    public String getBrief() {
+        return toJson(false).toString(1);
+    }
+
+    public JSONObject toJson(boolean verbose) {
         JSONObject root = new JSONObject();
         root.put("name", name);
         root.put("database", dbName);
-        root.put("id", dbId);
+        if (verbose) {
+            root.put("id", dbId);
+        }
         root.put("backup_time", backupTime);
         JSONObject backupObj = new JSONObject();
         root.put("backup_objects", backupObj);
@@ -427,33 +434,37 @@ public JSONObject toJson() {
         
         for (BackupTableInfo tblInfo : tables.values()) {
             JSONObject tbl = new JSONObject();
-            tbl.put("id", tblInfo.id);
+            if (verbose) {
+                tbl.put("id", tblInfo.id);
+            }
             JSONObject parts = new JSONObject();
             tbl.put("partitions", parts);
             for (BackupPartitionInfo partInfo : tblInfo.partitions.values()) {
                 JSONObject part = new JSONObject();
-                part.put("id", partInfo.id);
-                part.put("version", partInfo.version);
-                part.put("version_hash", partInfo.versionHash);
-                JSONObject indexes = new JSONObject();
-                part.put("indexes", indexes);
-                for (BackupIndexInfo idxInfo : partInfo.indexes.values()) {
-                    JSONObject idx = new JSONObject();
-                    idx.put("id", idxInfo.id);
-                    idx.put("schema_hash", idxInfo.schemaHash);
-                    JSONObject tablets = new JSONObject();
-                    JSONArray tabletsOrder = new JSONArray();
-                    idx.put("tablets", tablets);
-                    for (BackupTabletInfo tabletInfo : idxInfo.tablets) {
-                        JSONArray files = new JSONArray();
-                        tablets.put(String.valueOf(tabletInfo.id), files);
-                        for (String fileName : tabletInfo.files) {
-                            files.put(fileName);
+                if (verbose) {
+                    part.put("id", partInfo.id);
+                    part.put("version", partInfo.version);
+                    part.put("version_hash", partInfo.versionHash);
+                    JSONObject indexes = new JSONObject();
+                    part.put("indexes", indexes);
+                    for (BackupIndexInfo idxInfo : partInfo.indexes.values()) {
+                        JSONObject idx = new JSONObject();
+                        idx.put("id", idxInfo.id);
+                        idx.put("schema_hash", idxInfo.schemaHash);
+                        JSONObject tablets = new JSONObject();
+                        JSONArray tabletsOrder = new JSONArray();
+                        idx.put("tablets", tablets);
+                        for (BackupTabletInfo tabletInfo : idxInfo.tablets) {
+                            JSONArray files = new JSONArray();
+                            tablets.put(String.valueOf(tabletInfo.id), files);
+                            for (String fileName : tabletInfo.files) {
+                                files.put(fileName);
+                            }
+                            // to save the order of tablets
+                            tabletsOrder.put(String.valueOf(tabletInfo.id));
                         }
-                        // to save the order of tablets
-                        tabletsOrder.put(String.valueOf(tabletInfo.id));
+                        indexes.put(idxInfo.name, idx);
                     }
-                    indexes.put(idxInfo.name, idx);
                 }
                 parts.put(partInfo.name, part);
             }
@@ -465,7 +476,7 @@ public JSONObject toJson() {
     }
 
     public String toString(int indentFactor) {
-        return toJson().toString(indentFactor);
+        return toJson(true).toString(indentFactor);
     }
 
     public String getInfo() {
@@ -491,7 +502,7 @@ public static BackupJobInfo read(DataInput in) throws 
IOException {
 
     @Override
     public void write(DataOutput out) throws IOException {
-        Text.writeString(out, toJson().toString());
+        Text.writeString(out, toJson(true).toString());
         out.writeInt(tblAlias.size());
         for (Map.Entry<String, String> entry : tblAlias.entrySet()) {
             Text.writeString(out, entry.getKey());
@@ -513,7 +524,7 @@ public void readFields(DataInput in) throws IOException {
 
     @Override
     public String toString() {
-        return toJson().toString();
+        return toJson(true).toString();
     }
 }
 
diff --git a/fe/src/main/java/org/apache/doris/backup/BlobStorage.java 
b/fe/src/main/java/org/apache/doris/backup/BlobStorage.java
index 214678f3..bda5c02b 100644
--- a/fe/src/main/java/org/apache/doris/backup/BlobStorage.java
+++ b/fe/src/main/java/org/apache/doris/backup/BlobStorage.java
@@ -26,11 +26,13 @@
 import org.apache.doris.common.Pair;
 import org.apache.doris.common.io.Text;
 import org.apache.doris.common.io.Writable;
+import org.apache.doris.common.util.BrokerUtil;
 import org.apache.doris.service.FrontendOptions;
 import org.apache.doris.thrift.TBrokerCheckPathExistRequest;
 import org.apache.doris.thrift.TBrokerCheckPathExistResponse;
 import org.apache.doris.thrift.TBrokerCloseReaderRequest;
 import org.apache.doris.thrift.TBrokerCloseWriterRequest;
+import org.apache.doris.thrift.TBrokerDeletePathRequest;
 import org.apache.doris.thrift.TBrokerFD;
 import org.apache.doris.thrift.TBrokerFileStatus;
 import org.apache.doris.thrift.TBrokerListPathRequest;
@@ -125,8 +127,8 @@ public Status downloadWithFileSize(String remoteFilePath, 
String localFilePath,
             TBrokerOperationStatus opst = rep.getOpStatus();
             if (opst.getStatusCode() != TBrokerOperationStatusCode.OK) {
                 return new Status(ErrCode.COMMON_ERROR,
-                        "failed to open reader on broker " + brokerName + " 
for file: "
-                                + remoteFilePath + ". msg: " + 
opst.getMessage());
+                        "failed to open reader on broker " + 
BrokerUtil.printBroker(brokerName, address)
+                                + " for file: " + remoteFilePath + ". msg: " + 
opst.getMessage());
             }
 
             fd = rep.getFd();
@@ -134,8 +136,8 @@ public Status downloadWithFileSize(String remoteFilePath, 
String localFilePath,
                      fd, remoteFilePath, localFilePath);
         } catch (TException e) {
             return new Status(ErrCode.COMMON_ERROR,
-                    "failed to open reader on broker " + brokerName + " for 
file: "
-                            + remoteFilePath + ". msg: " + e.getMessage());
+                    "failed to open reader on broker " + 
BrokerUtil.printBroker(brokerName, address)
+                            + " for file: " + remoteFilePath + ". msg: " + 
e.getMessage());
         }
         Preconditions.checkNotNull(fd);
 
@@ -182,7 +184,8 @@ public Status downloadWithFileSize(String remoteFilePath, 
String localFilePath,
                             lastErrMsg = String.format("failed to read via 
broker %s. "
                                     + "current read offset: %d, read length: 
%d,"
                                     + " file size: %d, file: %s, err code: %d, 
msg: %s",
-                                    brokerName, readOffset, readLen, fileSize,
+                                    BrokerUtil.printBroker(brokerName, 
address),
+                                    readOffset, readLen, fileSize,
                                     remoteFilePath, 
rep.getOpStatus().getStatusCode(), 
                                     rep.getOpStatus().getMessage());
                             LOG.warn(lastErrMsg);
@@ -197,7 +200,8 @@ public Status downloadWithFileSize(String remoteFilePath, 
String localFilePath,
                             lastErrMsg = String.format("failed to read via 
broker %s. "
                                     + "current read offset: %d, read length: 
%d,"
                                     + " file size: %d, file: %s, timeout.",
-                                    brokerName, readOffset, readLen, fileSize,
+                                    BrokerUtil.printBroker(brokerName, 
address),
+                                    readOffset, readLen, fileSize,
                                     remoteFilePath);
                             tryTimes++;
                             continue;
@@ -206,7 +210,8 @@ public Status downloadWithFileSize(String remoteFilePath, 
String localFilePath,
                         lastErrMsg = String.format("failed to read via broker 
%s. "
                                 + "current read offset: %d, read length: %d,"
                                 + " file size: %d, file: %s. msg: %s",
-                                brokerName, readOffset, readLen, fileSize,
+                                BrokerUtil.printBroker(brokerName, address),
+                                readOffset, readLen, fileSize,
                                 remoteFilePath, e.getMessage());
                         LOG.warn(lastErrMsg);
                         status = new Status(ErrCode.COMMON_ERROR, lastErrMsg);
@@ -215,7 +220,8 @@ public Status downloadWithFileSize(String remoteFilePath, 
String localFilePath,
                         lastErrMsg = String.format("failed to read via broker 
%s. "
                                 + "current read offset: %d, read length: %d,"
                                 + " file size: %d, file: %s. msg: %s",
-                                brokerName, readOffset, readLen, fileSize,
+                                BrokerUtil.printBroker(brokerName, address),
+                                readOffset, readLen, fileSize,
                                 remoteFilePath, e.getMessage());
                         LOG.warn(lastErrMsg);
                         status = new Status(ErrCode.COMMON_ERROR, lastErrMsg);
@@ -231,8 +237,9 @@ public Status downloadWithFileSize(String remoteFilePath, 
String localFilePath,
                     // I don't know why, but have to adapt to it.
                     if (rep.getData().length != readLen) {
                         LOG.warn("the actual read length does not equal to "
-                                + "the expected read length: {} vs. {}, file: 
{}",
-                                 rep.getData().length, readLen, 
remoteFilePath);
+                                + "the expected read length: {} vs. {}, file: 
{}, broker: {}",
+                                 rep.getData().length, readLen, remoteFilePath,
+                                BrokerUtil.printBroker(brokerName, address));
                     }
 
                     out.write(rep.getData());
@@ -244,10 +251,11 @@ public Status downloadWithFileSize(String remoteFilePath, 
String localFilePath,
                 }
             } // end of reading remote file
         } catch (IOException e) {
-            return new Status(ErrCode.COMMON_ERROR, "Got exception: " + 
e.getMessage());
+            return new Status(ErrCode.COMMON_ERROR, "Got exception: " + 
e.getMessage() + ", broker: " +
+                    BrokerUtil.printBroker(brokerName, address))  ;
         } finally {
             // close broker reader
-            Status closeStatus = closeReader(client, fd);
+            Status closeStatus = closeReader(client, address, fd);
             if (!closeStatus.ok()) {
                 LOG.warn(closeStatus.getErrMsg());
                 if (status.ok()) {
@@ -281,7 +289,7 @@ public Status directUpload(String content, String 
remoteFile) {
 
         TBrokerFD fd = new TBrokerFD();
         try {
-            // 2. open file write with broker
+            // 2. open file writer with broker
             status = openWriter(client, address, remoteFile, fd);
             if (!status.ok()) {
                 return status;
@@ -294,15 +302,17 @@ public Status directUpload(String content, String 
remoteFile) {
                 TBrokerOperationStatus opst = client.pwrite(req);
                 if (opst.getStatusCode() != TBrokerOperationStatusCode.OK) {
                     // pwrite return failure.
-                    status = new Status(ErrCode.COMMON_ERROR, "write failed: " 
+ opst.getMessage());
+                    status = new Status(ErrCode.COMMON_ERROR, "write failed: " 
+ opst.getMessage()
+                            + ", broker: " + 
BrokerUtil.printBroker(brokerName, address));
                 }
             } catch (TException e) {
-                status = new Status(ErrCode.BAD_CONNECTION, "write exception: 
" + e.getMessage());
+                status = new Status(ErrCode.BAD_CONNECTION, "write exception: 
" + e.getMessage()
+                        + ", broker: " + BrokerUtil.printBroker(brokerName, 
address));
             } catch (UnsupportedEncodingException e) {
                 status = new Status(ErrCode.COMMON_ERROR, "unsupported 
encoding: " + e.getMessage());
             }
         } finally {
-            Status closeStatus = closeWriter(client, fd);
+            Status closeStatus = closeWriter(client, address, fd);
             if (closeStatus.getErrCode() == ErrCode.BAD_CONNECTION || 
status.getErrCode() == ErrCode.BAD_CONNECTION) {
                 ClientPool.brokerPool.invalidateObject(address, client);
             } else {
@@ -359,7 +369,8 @@ public Status upload(String localPath, String remotePath) {
                             lastErrMsg = String.format("failed to write via 
broker %s. "
                                     + "current write offset: %d, write length: 
%d,"
                                     + " file length: %d, file: %s, err code: 
%d, msg: %s",
-                                    brokerName, writeOffset, bytesRead, 
fileLength,
+                                    BrokerUtil.printBroker(brokerName, 
address),
+                                    writeOffset, bytesRead, fileLength,
                                     remotePath, opst.getStatusCode(), 
opst.getMessage());
                             LOG.warn(lastErrMsg);
                             status = new Status(ErrCode.COMMON_ERROR, 
lastErrMsg);
@@ -371,7 +382,8 @@ public Status upload(String localPath, String remotePath) {
                             lastErrMsg = String.format("failed to write via 
broker %s. "
                                     + "current write offset: %d, write length: 
%d,"
                                     + " file length: %d, file: %s. timeout",
-                                    brokerName, writeOffset, bytesRead, 
fileLength,
+                                    BrokerUtil.printBroker(brokerName, 
address),
+                                    writeOffset, bytesRead, fileLength,
                                     remotePath);
                             tryTimes++;
                             continue;
@@ -380,7 +392,8 @@ public Status upload(String localPath, String remotePath) {
                         lastErrMsg = String.format("failed to write via broker 
%s. "
                                 + "current write offset: %d, write length: %d,"
                                 + " file length: %d, file: %s. encounter 
TTransportException: %s",
-                                brokerName, writeOffset, bytesRead, fileLength,
+                                BrokerUtil.printBroker(brokerName, address),
+                                writeOffset, bytesRead, fileLength,
                                 remotePath, e.getMessage());
                         LOG.warn(lastErrMsg, e);
                         status = new Status(ErrCode.COMMON_ERROR, lastErrMsg);
@@ -389,7 +402,8 @@ public Status upload(String localPath, String remotePath) {
                         lastErrMsg = String.format("failed to write via broker 
%s. "
                                 + "current write offset: %d, write length: %d,"
                                 + " file length: %d, file: %s. encounter 
TException: %s",
-                                brokerName, writeOffset, bytesRead, fileLength,
+                                BrokerUtil.printBroker(brokerName, address),
+                                writeOffset, bytesRead, fileLength,
                                 remotePath, e.getMessage());
                         LOG.warn(lastErrMsg, e);
                         status = new Status(ErrCode.COMMON_ERROR, lastErrMsg);
@@ -406,12 +420,14 @@ public Status upload(String localPath, String remotePath) 
{
                 }
             } // end of read local file loop
         } catch (FileNotFoundException e1) {
-            return new Status(ErrCode.COMMON_ERROR, "encounter file not found 
exception: " + e1.getMessage());
+            return new Status(ErrCode.COMMON_ERROR, "encounter file not found 
exception: " + e1.getMessage()
+                    + ", broker: " + BrokerUtil.printBroker(brokerName, 
address));
         } catch (IOException e1) {
-            return new Status(ErrCode.COMMON_ERROR, "encounter io exception: " 
+ e1.getMessage());
+            return new Status(ErrCode.COMMON_ERROR, "encounter io exception: " 
+ e1.getMessage()
+                    + ", broker: " + BrokerUtil.printBroker(brokerName, 
address));
         } finally {
             // close write
-            Status closeStatus = closeWriter(client, fd);
+            Status closeStatus = closeWriter(client, address, fd);
             if (!closeStatus.ok()) {
                 LOG.warn(closeStatus.getErrMsg());
                 if (status.ok()) {
@@ -453,12 +469,14 @@ public Status rename(String origFilePath, String 
destFilePath) {
             TBrokerOperationStatus ost = client.renamePath(req);
             if (ost.getStatusCode() != TBrokerOperationStatusCode.OK) {
                 return new Status(ErrCode.COMMON_ERROR,
-                        "failed to rename " + origFilePath + " to " + 
destFilePath + ", msg: " + ost.getMessage());
+                        "failed to rename " + origFilePath + " to " + 
destFilePath + ", msg: " + ost.getMessage()
+                                + ", broker: " + 
BrokerUtil.printBroker(brokerName, address));
             }
         } catch (TException e) {
             needReturn = false;
             return new Status(ErrCode.COMMON_ERROR,
-                    "failed to rename " + origFilePath + " to " + destFilePath 
+ ", msg: " + e.getMessage());
+                    "failed to rename " + origFilePath + " to " + destFilePath 
+ ", msg: " + e.getMessage()
+                    + ", broker: " + BrokerUtil.printBroker(brokerName, 
address));
         } finally {
             if (needReturn) {
                 ClientPool.brokerPool.returnObject(address, client);
@@ -473,6 +491,42 @@ public Status rename(String origFilePath, String 
destFilePath) {
     }
 
     public Status delete(String remotePath) {
+        // get a proper broker
+        Pair<TPaloBrokerService.Client, TNetworkAddress> pair = new 
Pair<TPaloBrokerService.Client, TNetworkAddress>(
+                null, null);
+        Status st = getBroker(pair);
+        if (!st.ok()) {
+            return st;
+        }
+        TPaloBrokerService.Client client = pair.first;
+        TNetworkAddress address = pair.second;
+
+        // delete
+        boolean needReturn = true;
+        try {
+            TBrokerDeletePathRequest req = new 
TBrokerDeletePathRequest(TBrokerVersion.VERSION_ONE, remotePath,
+                    properties);
+            TBrokerOperationStatus opst = client.deletePath(req);
+            if (opst.getStatusCode() != TBrokerOperationStatusCode.OK) {
+                return new Status(ErrCode.COMMON_ERROR,
+                        "failed to delete remote path: " + remotePath + ". 
msg: " + opst.getMessage()
+                                + ", broker: " + 
BrokerUtil.printBroker(brokerName, address));
+            }
+
+            LOG.info("finished to delete remote path {}.", remotePath);
+        } catch (TException e) {
+            needReturn = false;
+            return new Status(ErrCode.COMMON_ERROR,
+                    "failed to delete remote path: " + remotePath + ". msg: " 
+ e.getMessage()
+                            + ", broker: " + 
BrokerUtil.printBroker(brokerName, address));
+        } finally {
+            if (needReturn) {
+                ClientPool.brokerPool.returnObject(address, client);
+            } else {
+                ClientPool.brokerPool.invalidateObject(address, client);
+            }
+        }
+
         return Status.OK;
     }
 
@@ -498,7 +552,8 @@ public Status list(String remotePath, List<RemoteFile> 
result) {
             TBrokerOperationStatus opst = rep.getOpStatus();
             if (opst.getStatusCode() != TBrokerOperationStatusCode.OK) {
                 return new Status(ErrCode.COMMON_ERROR,
-                        "failed to list remote path: " + remotePath + ". msg: 
" + opst.getMessage());
+                        "failed to list remote path: " + remotePath + ". msg: 
" + opst.getMessage()
+                                + ", broker: " + 
BrokerUtil.printBroker(brokerName, address));
             }
 
             List<TBrokerFileStatus> fileStatus = rep.getFiles();
@@ -510,7 +565,8 @@ public Status list(String remotePath, List<RemoteFile> 
result) {
         } catch (TException e) {
             needReturn = false;
             return new Status(ErrCode.COMMON_ERROR,
-                    "failed to list remote path: " + remotePath + ". msg: " + 
e.getMessage());
+                    "failed to list remote path: " + remotePath + ". msg: " + 
e.getMessage()
+                            + ", broker: " + 
BrokerUtil.printBroker(brokerName, address));
         } finally {
             if (needReturn) {
                 ClientPool.brokerPool.returnObject(address, client);
@@ -557,7 +613,9 @@ public Status checkPathExist(String remotePath) {
             TBrokerOperationStatus opst = rep.getOpStatus();
             if (opst.getStatusCode() != TBrokerOperationStatusCode.OK) {
                 return new Status(ErrCode.COMMON_ERROR,
-                        "failed to check remote path exist: " + remotePath + 
". msg: " + opst.getMessage());
+                        "failed to check remote path exist: " + remotePath
+                                + ", broker: " + 
BrokerUtil.printBroker(brokerName, address)
+                                + ". msg: " + opst.getMessage());
             }
 
             if (!rep.isIsPathExist()) {
@@ -568,7 +626,9 @@ public Status checkPathExist(String remotePath) {
         } catch (TException e) {
             needReturn = false;
             return new Status(ErrCode.COMMON_ERROR,
-                    "failed to check remote path exist: " + remotePath + ". 
msg: " + e.getMessage());
+                    "failed to check remote path exist: " + remotePath
+                            + ", broker: " + 
BrokerUtil.printBroker(brokerName, address)
+                            + ". msg: " + e.getMessage());
         } finally {
             if (needReturn) {
                 ClientPool.brokerPool.returnObject(address, client);
@@ -600,6 +660,7 @@ private Status getBroker(Pair<TPaloBrokerService.Client, 
TNetworkAddress> result
 
         result.first = client;
         result.second = address;
+        LOG.info("get broker: {}", BrokerUtil.printBroker(brokerName, 
address));
         return Status.OK;
     }
 
@@ -612,8 +673,8 @@ private Status openWriter(TPaloBrokerService.Client client, 
TNetworkAddress addr
             TBrokerOperationStatus opst = rep.getOpStatus();
             if (opst.getStatusCode() != TBrokerOperationStatusCode.OK) {
                 return new Status(ErrCode.COMMON_ERROR,
-                        "failed to open writer on broker " + brokerName + " 
for file: "
-                                + remoteFile + ". msg: " + opst.getMessage());
+                        "failed to open writer on broker " + 
BrokerUtil.printBroker(brokerName, address)
+                                + " for file: " + remoteFile + ". msg: " + 
opst.getMessage());
             }
 
             fd.setHigh(rep.getFd().getHigh());
@@ -622,43 +683,48 @@ private Status openWriter(TPaloBrokerService.Client 
client, TNetworkAddress addr
                      fd, remoteFile);
         } catch (TException e) {
             return new Status(ErrCode.BAD_CONNECTION,
-                    "failed to open writer on broker " + brokerName + ": " + 
e.getMessage());
+                    "failed to open writer on broker " + 
BrokerUtil.printBroker(brokerName, address)
+                            + ", err: " + e.getMessage());
         }
 
         return Status.OK;
     }
 
-    private Status closeWriter(TPaloBrokerService.Client client, TBrokerFD fd) 
{
+    private Status closeWriter(TPaloBrokerService.Client client, 
TNetworkAddress address, TBrokerFD fd) {
         try {
             TBrokerCloseWriterRequest req = new 
TBrokerCloseWriterRequest(TBrokerVersion.VERSION_ONE, fd);
             TBrokerOperationStatus st = client.closeWriter(req);
             if (st.getStatusCode() != TBrokerOperationStatusCode.OK) {
                 return new Status(ErrCode.COMMON_ERROR,
-                        "failed to close writer on broker " + brokerName + " 
for fd: " + fd);
+                        "failed to close writer on broker " + 
BrokerUtil.printBroker(brokerName, address)
+                                + " for fd: " + fd);
             }
 
             LOG.info("finished to close writer. fd: {}.", fd);
         } catch (TException e) {
             return new Status(ErrCode.BAD_CONNECTION,
-                    "failed to close writer on broker " + brokerName + ", fd " 
+ fd + ", msg: " + e.getMessage());
+                    "failed to close writer on broker " + 
BrokerUtil.printBroker(brokerName, address)
+                            + ", fd " + fd + ", msg: " + e.getMessage());
         }
 
         return Status.OK;
     }
 
-    private Status closeReader(TPaloBrokerService.Client client, TBrokerFD fd) 
{
+    private Status closeReader(TPaloBrokerService.Client client, 
TNetworkAddress address, TBrokerFD fd) {
         try {
             TBrokerCloseReaderRequest req = new 
TBrokerCloseReaderRequest(TBrokerVersion.VERSION_ONE, fd);
             TBrokerOperationStatus st = client.closeReader(req);
             if (st.getStatusCode() != TBrokerOperationStatusCode.OK) {
                 return new Status(ErrCode.COMMON_ERROR,
-                        "failed to close reader on broker " + brokerName + " 
for fd: " + fd);
+                        "failed to close reader on broker " + 
BrokerUtil.printBroker(brokerName, address)
+                                + " for fd: " + fd);
             }
 
             LOG.info("finished to close reader. fd: {}.", fd);
         } catch (TException e) {
             return new Status(ErrCode.BAD_CONNECTION,
-                    "failed to close reader on broker " + brokerName + ", fd " 
+ fd + ", msg: " + e.getMessage());
+                    "failed to close reader on broker " + 
BrokerUtil.printBroker(brokerName, address)
+                            + ", fd " + fd + ", msg: " + e.getMessage());
         }
 
         return Status.OK;
diff --git a/fe/src/main/java/org/apache/doris/backup/Repository.java 
b/fe/src/main/java/org/apache/doris/backup/Repository.java
index e0d9199c..03397916 100644
--- a/fe/src/main/java/org/apache/doris/backup/Repository.java
+++ b/fe/src/main/java/org/apache/doris/backup/Repository.java
@@ -373,8 +373,14 @@ public Status upload(String localFilePath, String 
remoteFilePath) {
         String tmpRemotePath = assembleFileNameWithSuffix(remoteFilePath, 
SUFFIX_TMP_FILE);
         LOG.debug("get md5sum of file: {}. tmp remote path: {}", 
localFilePath, tmpRemotePath);
 
+        // this may be a retry, so we should first delete remote file
+        Status st = storage.delete(tmpRemotePath);
+        if (!st.ok()) {
+            return st;
+        }
+
         // upload tmp file
-        Status st = storage.upload(localFilePath, tmpRemotePath);
+        st = storage.upload(localFilePath, tmpRemotePath);
         if (!st.ok()) {
             return st;
         }
@@ -598,7 +604,7 @@ public Status getBrokerAddress(Long beId, Catalog catalog, 
List<FsBroker> broker
                         info.add(snapshotName);
                         info.add(timestamp);
                         info.add(jobInfo.dbName);
-                        info.add(jobInfo.toString(1));
+                        info.add(jobInfo.getBrief());
                         info.add("OK");
                     } catch (IOException e) {
                         info.add(snapshotName);
diff --git a/fe/src/main/java/org/apache/doris/backup/RestoreJob.java 
b/fe/src/main/java/org/apache/doris/backup/RestoreJob.java
index 5c2bf84b..cb793ad9 100644
--- a/fe/src/main/java/org/apache/doris/backup/RestoreJob.java
+++ b/fe/src/main/java/org/apache/doris/backup/RestoreJob.java
@@ -189,6 +189,7 @@ public synchronized boolean 
finishTabletSnapshotTask(SnapshotTask task, TFinishT
                 task.getSchemaHash(), request.getSnapshot_path(), 
Lists.newArrayList());
 
         snapshotInfos.put(task.getTabletId(), task.getBackendId(), info);
+        taskProgress.remove(task.getSignature());
         Long removedTabletId = 
unfinishedSignatureToId.remove(task.getSignature());
         if (removedTabletId != null) {
             taskErrMsg.remove(task.getSignature());
@@ -221,6 +222,7 @@ public synchronized boolean 
finishTabletDownloadTask(DownloadTask task, TFinishT
             }
         }
 
+        taskProgress.remove(task.getSignature());
         Long beId = unfinishedSignatureToId.remove(task.getSignature());
         if (beId == null || beId != task.getBackendId()) {
             LOG.error("invalid download task: {}. {}", task, this);
@@ -240,6 +242,7 @@ public synchronized boolean finishDirMoveTask(DirMoveTask 
task, TFinishTaskReque
             return false;
         }
 
+        taskProgress.remove(task.getSignature());
         Long tabletId = unfinishedSignatureToId.remove(task.getSignature());
         if (tabletId == null || tabletId != task.getTabletId()) {
             LOG.error("invalid dir move task: {}. {}", task, this);
@@ -304,27 +307,31 @@ public void run() {
 
         LOG.info("run restore job: {}", this);
 
-        switch (state) {
-            case PENDING:
-                checkAndPrepareMeta();
-                break;
-            case SNAPSHOTING:
-                waitingAllSnapshotsFinished();
-                break;
-            case DOWNLOAD:
-                downloadSnapshots();
-                break;
-            case DOWNLOADING:
-                waitingAllDownloadFinished();
-                break;
-            case COMMIT:
-                commit();
-                break;
-            case COMMITTING:
-                waitingAllTabletsCommitted();
-                break;
-            default:
-                break;
+        checkIfNeedCancel();
+
+        if (status.ok()) {
+            switch (state) {
+                case PENDING:
+                    checkAndPrepareMeta();
+                    break;
+                case SNAPSHOTING:
+                    waitingAllSnapshotsFinished();
+                    break;
+                case DOWNLOAD:
+                    downloadSnapshots();
+                    break;
+                case DOWNLOADING:
+                    waitingAllDownloadFinished();
+                    break;
+                case COMMIT:
+                    commit();
+                    break;
+                case COMMITTING:
+                    waitingAllTabletsCommitted();
+                    break;
+                default:
+                    break;
+            }
         }
 
         if (!status.ok()) {
@@ -332,6 +339,45 @@ public void run() {
         }
     }
 
+    /*
+     * return true if some restored objs have been dropped.
+     */
+    private void checkIfNeedCancel() {
+        if (state == RestoreJobState.PENDING) {
+            return;
+        }
+
+        Database db = catalog.getDb(dbId);
+        if (db == null) {
+            status = new Status(ErrCode.NOT_FOUND, "database " + dbId + " has 
been dropped");
+        }
+
+        db.readLock();
+        try {
+            for (IdChain idChain : fileMapping.getMapping().keySet()) {
+                OlapTable tbl = (OlapTable) db.getTable(idChain.getTblId());
+                if (tbl == null) {
+                    status = new Status(ErrCode.NOT_FOUND, "table " + 
idChain.getTblId() + " has been dropped");
+                    return;
+                }
+
+                Partition part = tbl.getPartition(idChain.getPartId());
+                if (part == null) {
+                    status = new Status(ErrCode.NOT_FOUND, "partition " + 
idChain.getPartId() + " has been dropped");
+                    return;
+                }
+
+                MaterializedIndex index = part.getIndex(idChain.getIdxId());
+                if (index == null) {
+                    status = new Status(ErrCode.NOT_FOUND, "index " + 
idChain.getIdxId() + " has been dropped");
+                    return;
+                }
+            }
+        } finally {
+            db.readUnlock();
+        }
+    }
+
     /*
      * Restore rules as follow:
      * A. Table already exist
@@ -644,9 +690,9 @@ private void checkAndPrepareMeta() {
             }
             AgentTaskExecutor.submit(batchTask);
 
-            // estimate timeout, at most 10 seconds
+            // estimate timeout, at most 10 min
             long timeout = Config.tablet_create_timeout_second * 1000L * 
batchTask.getTaskNum();
-            timeout = Math.min(10 * 1000, timeout);
+            timeout = Math.min(10 * 60 * 1000, timeout);
             boolean ok = false;
             try {
                 LOG.info("begin to send create replica tasks to BE for 
restore. total {} tasks. timeout: {}",
@@ -708,6 +754,7 @@ private void checkAndPrepareMeta() {
         // begin to make snapshots for all replicas
         // snapshot is for incremental download
         unfinishedSignatureToId.clear();
+        taskProgress.clear();
         taskErrMsg.clear();
         batchTask = new AgentBatchTask();
         db.readLock();
@@ -939,6 +986,7 @@ private void downloadSnapshots() {
 
         // Send download tasks
         unfinishedSignatureToId.clear();
+        taskProgress.clear();
         taskErrMsg.clear();
         AgentBatchTask batchTask = new AgentBatchTask();
         for (long dbId : dbToSnapshotInfos.keySet()) {
@@ -1090,6 +1138,7 @@ private void waitingAllDownloadFinished() {
     private void commit() {
         // Send task to move the download dir
         unfinishedSignatureToId.clear();
+        taskProgress.clear();
         taskErrMsg.clear();
         AgentBatchTask batchTask = new AgentBatchTask();
         // tablet id->(be id -> download info)
@@ -1214,9 +1263,11 @@ private void replayWaitingAllTabletsCommitted() {
         info.add(TimeUtils.longToTimeString(downloadFinishedTime));
         info.add(TimeUtils.longToTimeString(finishedTime));
         info.add(Joiner.on(", ").join(unfinishedSignatureToId.keySet()));
-        List<String> msgs = taskErrMsg.entrySet().stream().map(n -> "[" + 
n.getKey() + ": " + n.getValue()
-                + "]").collect(Collectors.toList());
-        info.add(Joiner.on(", ").join(msgs));
+        info.add(Joiner.on(", ").join(taskProgress.entrySet().stream().map(
+                e -> "[" + e.getKey() + ": " + e.getValue().first + "/" + 
e.getValue().second + "]").collect(
+                        Collectors.toList())));
+        info.add(Joiner.on(", ").join(taskErrMsg.entrySet().stream().map(n -> 
"[" + n.getKey() + ": " + n.getValue()
+                + "]").collect(Collectors.toList())));
         info.add(status.toString());
         info.add(String.valueOf(timeoutMs / 1000));
         return info;
diff --git a/fe/src/main/java/org/apache/doris/catalog/Catalog.java 
b/fe/src/main/java/org/apache/doris/catalog/Catalog.java
index 6e633b4c..fbb3245d 100644
--- a/fe/src/main/java/org/apache/doris/catalog/Catalog.java
+++ b/fe/src/main/java/org/apache/doris/catalog/Catalog.java
@@ -4486,6 +4486,10 @@ public FrontendNodeType getRole() {
         return this.helperNodes.get(0);
     }
 
+    public List<Pair<String, Integer>> getHelperNodes() {
+        return Lists.newArrayList(helperNodes);
+    }
+
     public Pair<String, Integer> getSelfNode() {
         return this.selfNode;
     }
diff --git a/fe/src/main/java/org/apache/doris/catalog/Column.java 
b/fe/src/main/java/org/apache/doris/catalog/Column.java
index ad17b4b6..419c72dd 100644
--- a/fe/src/main/java/org/apache/doris/catalog/Column.java
+++ b/fe/src/main/java/org/apache/doris/catalog/Column.java
@@ -17,13 +17,15 @@
 
 package org.apache.doris.catalog;
 
-import com.google.common.base.Strings;
 import org.apache.doris.common.DdlException;
 import org.apache.doris.common.FeMetaVersion;
 import org.apache.doris.common.io.Text;
 import org.apache.doris.common.io.Writable;
 import org.apache.doris.thrift.TColumn;
 import org.apache.doris.thrift.TColumnType;
+
+import com.google.common.base.Strings;
+
 import org.apache.logging.log4j.LogManager;
 import org.apache.logging.log4j.Logger;
 
@@ -249,7 +251,7 @@ public String toSql() {
         StringBuilder sb = new StringBuilder();
         sb.append("`").append(name).append("` ");
         sb.append(type.toSql()).append(" ");
-        if (aggregationType != null && !isAggregationTypeImplicit) {
+        if (aggregationType != null && aggregationType != AggregateType.NONE 
&& !isAggregationTypeImplicit) {
             sb.append(aggregationType.name()).append(" ");
         }
         if (!isAllowNull) {
diff --git a/fe/src/main/java/org/apache/doris/common/Config.java 
b/fe/src/main/java/org/apache/doris/common/Config.java
index 1e36e74d..3bddd82e 100644
--- a/fe/src/main/java/org/apache/doris/common/Config.java
+++ b/fe/src/main/java/org/apache/doris/common/Config.java
@@ -185,7 +185,6 @@
     @ConfField public static int http_port = 8030;
     /*
      * FE thrift server port
-     * 
      */
     @ConfField public static int rpc_port = 9020;
     /*
diff --git a/fe/src/main/java/org/apache/doris/common/io/DeepCopy.java 
b/fe/src/main/java/org/apache/doris/common/io/DeepCopy.java
index 94418d41..ed14a82d 100644
--- a/fe/src/main/java/org/apache/doris/common/io/DeepCopy.java
+++ b/fe/src/main/java/org/apache/doris/common/io/DeepCopy.java
@@ -17,6 +17,9 @@
 
 package org.apache.doris.common.io;
 
+import org.apache.doris.common.FeConstants;
+import org.apache.doris.meta.MetaContext;
+
 import org.apache.logging.log4j.LogManager;
 import org.apache.logging.log4j.Logger;
 
@@ -27,6 +30,10 @@
     private static final Logger LOG = LogManager.getLogger(DeepCopy.class);
 
     public static boolean copy(Writable orig, Writable copied) {
+        MetaContext metaContext = new MetaContext();
+        metaContext.setMetaVersion(FeConstants.meta_version);
+        metaContext.setThreadLocalInfo();
+
         FastByteArrayOutputStream byteArrayOutputStream = new 
FastByteArrayOutputStream();
         DataOutputStream out = new DataOutputStream(byteArrayOutputStream);
         try {
@@ -41,6 +48,8 @@ public static boolean copy(Writable orig, Writable copied) {
             e.printStackTrace();
             LOG.warn("failed to copy object.", e);
             return false;
+        } finally {
+            MetaContext.remove();
         }
         return true;
     }
diff --git 
a/fe/src/main/java/org/apache/doris/common/proc/FrontendsProcNode.java 
b/fe/src/main/java/org/apache/doris/common/proc/FrontendsProcNode.java
index d33ccff3..e6be11fb 100644
--- a/fe/src/main/java/org/apache/doris/common/proc/FrontendsProcNode.java
+++ b/fe/src/main/java/org/apache/doris/common/proc/FrontendsProcNode.java
@@ -38,7 +38,7 @@
     public static final ImmutableList<String> TITLE_NAMES = new 
ImmutableList.Builder<String>()
             
.add("name").add("Host").add("EditLogPort").add("HttpPort").add("QueryPort").add("RpcPort")
             
.add("Role").add("IsMaster").add("ClusterId").add("Join").add("IsAlive")
-            .add("ReplayedJournalId").add("LstUpdateTime")
+            .add("ReplayedJournalId").add("LstUpdateTime").add("IsHelper")
             .build();
     
     private Catalog catalog;
@@ -72,6 +72,7 @@ public static void getFrontendsInfo(Catalog catalog, 
List<List<String>> infos) {
         List<InetSocketAddress> allFe = 
catalog.getHaProtocol().getElectableNodes(true /* include leader */);
         allFe.addAll(catalog.getHaProtocol().getObserverNodes());
         List<Pair<String, Integer>> allFeHosts = convertToHostPortPair(allFe);
+        List<Pair<String, Integer>> helperNodes = catalog.getHelperNodes();
         
         for (Frontend fe : catalog.getFrontends(null /* all */)) {
 
@@ -104,10 +105,16 @@ public static void getFrontendsInfo(Catalog catalog, 
List<List<String>> infos) {
             }
             info.add(TimeUtils.longToTimeString(fe.getLastUpdateTime()));
             
+            info.add(String.valueOf(isHelperNode(helperNodes, fe)));
+
             infos.add(info);
         }
     }
     
+    private static boolean isHelperNode(List<Pair<String, Integer>> 
helperNodes, Frontend fe) {
+        return helperNodes.stream().anyMatch(p -> p.first.equals(fe.getHost()) 
&& p.second == fe.getEditLogPort());
+    }
+
     private static boolean isJoin(List<Pair<String, Integer>> allFeHosts, 
Frontend fe) {
         for (Pair<String, Integer> pair : allFeHosts) {
             if (fe.getHost().equals(pair.first) && fe.getEditLogPort() == 
pair.second) {
diff --git a/fe/src/main/java/org/apache/doris/common/util/BrokerUtil.java 
b/fe/src/main/java/org/apache/doris/common/util/BrokerUtil.java
index 356644f9..a6cb6683 100644
--- a/fe/src/main/java/org/apache/doris/common/util/BrokerUtil.java
+++ b/fe/src/main/java/org/apache/doris/common/util/BrokerUtil.java
@@ -95,4 +95,8 @@ public static void parseBrokerFile(String path, BrokerDesc 
brokerDesc, List<TBro
         }
     }
 
+    public static String printBroker(String brokerName, TNetworkAddress 
address) {
+        return brokerName + "[" + address.toString() + "]";
+    }
+
 }
diff --git a/fe/src/main/java/org/apache/doris/qe/QeService.java 
b/fe/src/main/java/org/apache/doris/qe/QeService.java
index 56f71baf..88b50b75 100644
--- a/fe/src/main/java/org/apache/doris/qe/QeService.java
+++ b/fe/src/main/java/org/apache/doris/qe/QeService.java
@@ -18,8 +18,6 @@
 package org.apache.doris.qe;
 
 import org.apache.doris.catalog.Catalog;
-import org.apache.doris.common.Config;
-import org.apache.doris.common.UserException;
 import org.apache.doris.mysql.MysqlServer;
 
 import org.apache.logging.log4j.LogManager;
@@ -51,20 +49,6 @@ public QeService(int port, ConnectScheduler scheduler) {
         mysqlServer = new MysqlServer(port, scheduler);
     }
 
-    @Deprecated
-    public void setup() throws IOException, UserException {
-        // Set up help module
-        try {
-            HelpModule.getInstance().setUpModule();
-        } catch (Exception e) {
-            LOG.error("Help module failed, because:", e);
-        }
-        // setup MySQL protocol service
-        // TODO(zhaochun): remove settings.
-        ConnectScheduler scheduler = new 
ConnectScheduler(Config.qe_max_connection);
-        mysqlServer = new MysqlServer(port, scheduler);
-    }
-
     public void start() throws IOException {
         while (true) {
             if (!Catalog.getInstance().canRead()) {
diff --git a/fe/src/main/java/org/apache/doris/service/FrontendServiceImpl.java 
b/fe/src/main/java/org/apache/doris/service/FrontendServiceImpl.java
index e41ef307..739f5cf6 100644
--- a/fe/src/main/java/org/apache/doris/service/FrontendServiceImpl.java
+++ b/fe/src/main/java/org/apache/doris/service/FrontendServiceImpl.java
@@ -79,6 +79,7 @@
 import org.apache.doris.thrift.TReportRequest;
 import org.apache.doris.thrift.TShowVariableRequest;
 import org.apache.doris.thrift.TShowVariableResult;
+import org.apache.doris.thrift.TSnapshotLoaderReportRequest;
 import org.apache.doris.thrift.TStatus;
 import org.apache.doris.thrift.TStatusCode;
 import org.apache.doris.thrift.TStreamLoadPutRequest;
@@ -90,13 +91,13 @@
 import org.apache.doris.transaction.LabelAlreadyExistsException;
 import org.apache.doris.transaction.TabletCommitInfo;
 import org.apache.doris.transaction.TransactionState;
+import org.apache.doris.transaction.TxnCommitAttachment;
 
 import com.google.common.base.Joiner;
 import com.google.common.base.Strings;
 import com.google.common.collect.Lists;
 import com.google.common.collect.Maps;
 
-import org.apache.doris.transaction.TxnCommitAttachment;
 import org.apache.logging.log4j.LogManager;
 import org.apache.logging.log4j.Logger;
 import org.apache.thrift.TException;
@@ -760,5 +761,14 @@ private TExecPlanFragmentParams 
streamLoadPutImpl(TStreamLoadPutRequest request)
             db.readUnlock();
         }
     }
+
+    @Override
+    public TStatus snapshotLoaderReport(TSnapshotLoaderReportRequest request) 
throws TException {
+        if 
(Catalog.getCurrentCatalog().getBackupHandler().report(request.getTask_type(), 
request.getJob_id(),
+                request.getTask_id(), request.getFinished_num(), 
request.getTotal_num())) {
+            return new TStatus(TStatusCode.OK);
+        }
+        return new TStatus(TStatusCode.CANCELLED);
+    }
 }
 
diff --git a/fe/src/main/java/org/apache/doris/system/BrokerHbResponse.java 
b/fe/src/main/java/org/apache/doris/system/BrokerHbResponse.java
index 86ddc0d4..e6ae49b1 100644
--- a/fe/src/main/java/org/apache/doris/system/BrokerHbResponse.java
+++ b/fe/src/main/java/org/apache/doris/system/BrokerHbResponse.java
@@ -48,7 +48,7 @@ public BrokerHbResponse(String name, String host, int port, 
long hbTime) {
 
     public BrokerHbResponse(String name, String host, int port, String errMsg) 
{
         super(HeartbeatResponse.Type.BROKER);
-        this.status = HbStatus.OK;
+        this.status = HbStatus.BAD;
         this.name = name;
         this.host = host;
         this.port = port;
diff --git a/fe/src/test/java/org/apache/doris/backup/RepositoryTest.java 
b/fe/src/test/java/org/apache/doris/backup/RepositoryTest.java
index 19b6b4b3..3f6e447c 100644
--- a/fe/src/test/java/org/apache/doris/backup/RepositoryTest.java
+++ b/fe/src/test/java/org/apache/doris/backup/RepositoryTest.java
@@ -201,6 +201,9 @@ public void testUpload() {
 
                 storage.rename(anyString, anyString);
                 result = Status.OK;
+
+                storage.delete(anyString);
+                result = Status.OK;
             }
         };
 
diff --git a/fe/src/test/java/org/apache/doris/common/GenericPoolTest.java 
b/fe/src/test/java/org/apache/doris/common/GenericPoolTest.java
index da68702f..64432e38 100644
--- a/fe/src/test/java/org/apache/doris/common/GenericPoolTest.java
+++ b/fe/src/test/java/org/apache/doris/common/GenericPoolTest.java
@@ -64,37 +64,36 @@
     static ThriftServer service;
     static String ip = "127.0.0.1";
     static int port = 39401;
-    
+
     static void close() {
         if (service != null) {
             service.stop();
         }
     }
-    
+
     @BeforeClass
     public static void beforeClass() throws IOException {
         try {
             GenericKeyedObjectPoolConfig config = new 
GenericKeyedObjectPoolConfig();
-            config.setLifo(true);     // set Last In First Out strategy
-            config.setMaxIdlePerKey(2);      // (default 8)
-            config.setMinIdlePerKey(0);      // (default 0)
-            config.setMaxTotalPerKey(2);    // (default 8)
-            config.setMaxTotal(3);          // (default -1) 
-            config.setMaxWaitMillis(500);  
+            config.setLifo(true); // set Last In First Out strategy
+            config.setMaxIdlePerKey(2); // (default 8)
+            config.setMinIdlePerKey(0); // (default 0)
+            config.setMaxTotalPerKey(2); // (default 8)
+            config.setMaxTotal(3); // (default -1)
+            config.setMaxWaitMillis(500);
             // new ClientPool
             backendService = new GenericPool("BackendService", config, 0);
             // new ThriftService
-            TProcessor tprocessor = 
-                    new BackendService.Processor<BackendService.Iface>(
-                            new InternalProcessor());
+            TProcessor tprocessor = new 
BackendService.Processor<BackendService.Iface>(
+                    new InternalProcessor());
             service = new ThriftServer(port, tprocessor);
-            service.start();            
+            service.start();
         } catch (Exception e) {
             e.printStackTrace();
             close();
         }
     }
-    
+
     @AfterClass
     public static void afterClass() throws IOException {
         close();
@@ -104,18 +103,22 @@ public static void afterClass() throws IOException {
         public InternalProcessor() {
             //
         }
+
         @Override
         public TExecPlanFragmentResult 
exec_plan_fragment(TExecPlanFragmentParams params) {
             return new TExecPlanFragmentResult();
         }
+
         @Override
         public TCancelPlanFragmentResult 
cancel_plan_fragment(TCancelPlanFragmentParams params) {
             return new TCancelPlanFragmentResult();
         }
+
         @Override
         public TTransmitDataResult transmit_data(TTransmitDataParams params) {
             return new TTransmitDataResult();
         }
+
         @Override
         public TFetchDataResult fetch_data(TFetchDataParams params) {
             TFetchDataResult result = new TFetchDataResult();
@@ -215,7 +218,7 @@ public TTabletStatResult get_tablet_stat() throws 
TException {
             return null;
         }
     }
-    
+
     @Test
     public void testNormal() throws Exception {
         TNetworkAddress address = new TNetworkAddress(ip, port);
@@ -234,13 +237,13 @@ public void testSetMaxPerKey() throws Exception {
         BackendService.Client object1;
         BackendService.Client object2;
         BackendService.Client object3;
-        
+
         // first success
         object1 = backendService.borrowObject(address);
-        
+
         // second success
         object2 = backendService.borrowObject(address);
-        
+
         // third fail, because the max connection is 2
         boolean flag = false;
         try {
@@ -251,19 +254,19 @@ public void testSetMaxPerKey() throws Exception {
         } catch (Exception e) {
             // can't get here
             Assert.fail();
-        } 
+        }
         Assert.assertTrue(flag);
-        
+
         // fouth success, beacuse we drop the object1
         backendService.returnObject(address, object1);
         object3 = null;
         object3 = backendService.borrowObject(address);
-        Assert.assertTrue(object3 != null);  
-        
+        Assert.assertTrue(object3 != null);
+
         backendService.returnObject(address, object2);
         backendService.returnObject(address, object3);
     }
-    
+
     @Test
     public void testException() throws Exception {
         TNetworkAddress address = new TNetworkAddress(ip, port);
diff --git a/fe/src/test/java/org/apache/doris/system/HeartbeatMgrTest.java 
b/fe/src/test/java/org/apache/doris/system/HeartbeatMgrTest.java
index 510fcef1..3a34d75d 100644
--- a/fe/src/test/java/org/apache/doris/system/HeartbeatMgrTest.java
+++ b/fe/src/test/java/org/apache/doris/system/HeartbeatMgrTest.java
@@ -25,6 +25,7 @@
 import org.apache.doris.system.HeartbeatMgr.FrontendHeartbeatHandler;
 import org.apache.doris.system.HeartbeatResponse.HbStatus;
 import org.apache.doris.thrift.TBrokerOperationStatus;
+import org.apache.doris.thrift.TBrokerOperationStatusCode;
 import org.apache.doris.thrift.TBrokerPingBrokerRequest;
 import org.apache.doris.thrift.TNetworkAddress;
 import org.apache.doris.thrift.TPaloBrokerService;
@@ -86,6 +87,7 @@ public String getResultForUrl(String urlStr, String 
encodedAuthInfo, int connect
     @Test
     public void testBrokerHbHandler(@Mocked TPaloBrokerService.Client client) 
throws Exception {
         TBrokerOperationStatus status = new TBrokerOperationStatus();
+        status.setStatusCode(TBrokerOperationStatusCode.OK);
 
         new MockUp<GenericPool<TPaloBrokerService.Client>>() {
             @Mock
diff --git 
a/fs_brokers/apache_hdfs_broker/src/main/java/org/apache/doris/broker/hdfs/FileSystemManager.java
 
b/fs_brokers/apache_hdfs_broker/src/main/java/org/apache/doris/broker/hdfs/FileSystemManager.java
index 63af36ed..4a32f831 100644
--- 
a/fs_brokers/apache_hdfs_broker/src/main/java/org/apache/doris/broker/hdfs/FileSystemManager.java
+++ 
b/fs_brokers/apache_hdfs_broker/src/main/java/org/apache/doris/broker/hdfs/FileSystemManager.java
@@ -17,17 +17,25 @@
 
 package org.apache.doris.broker.hdfs;
 
-import com.google.common.base.Strings;
 import org.apache.doris.thrift.TBrokerFD;
 import org.apache.doris.thrift.TBrokerFileStatus;
 import org.apache.doris.thrift.TBrokerOperationStatusCode;
+
+import com.google.common.base.Strings;
+
 import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.fs.*;
+import org.apache.hadoop.fs.CommonConfigurationKeysPublic;
+import org.apache.hadoop.fs.FSDataInputStream;
+import org.apache.hadoop.fs.FSDataOutputStream;
+import org.apache.hadoop.fs.FileStatus;
+import org.apache.hadoop.fs.FileSystem;
+import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.security.UserGroupInformation;
 import org.apache.hadoop.util.StringUtils;
 import org.apache.log4j.Logger;
 
 import java.io.File;
+import java.io.FileNotFoundException;
 import java.io.FileOutputStream;
 import java.io.IOException;
 import java.net.InetAddress;
@@ -37,7 +45,12 @@
 import java.nio.ByteBuffer;
 import java.security.MessageDigest;
 import java.security.NoSuchAlgorithmException;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Base64;
+import java.util.List;
+import java.util.Map;
+import java.util.Random;
+import java.util.UUID;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.Executors;
 import java.util.concurrent.ScheduledExecutorService;
@@ -329,6 +342,10 @@ public BrokerFileSystem getFileSystem(String path, 
Map<String, String> propertie
                 }
                 resultFileStatus.add(brokerFileStatus);
             }
+        } catch (FileNotFoundException e) {
+            logger.info("file not found: " + e.getMessage());
+            throw new 
BrokerException(TBrokerOperationStatusCode.FILE_NOT_FOUND,
+                    e, "file not found");
         } catch (Exception e) {
             logger.error("errors while get file status ", e);
             fileSystem.closeFileSystem();
diff --git a/gensrc/thrift/FrontendService.thrift 
b/gensrc/thrift/FrontendService.thrift
index 90277d75..03ec7375 100644
--- a/gensrc/thrift/FrontendService.thrift
+++ b/gensrc/thrift/FrontendService.thrift
@@ -560,6 +560,13 @@ struct TLoadTxnRollbackResult {
     1: required Status.TStatus status
 }
 
+struct TSnapshotLoaderReportRequest {
+    1: required i64 job_id
+    2: required i64 task_id
+    3: required Types.TTaskType task_type
+    4: optional i32 finished_num
+    5: optional i32 total_num
+}
 
 service FrontendService {
     TGetDbsResult getDbNames(1:TGetDbsParams params)
@@ -587,4 +594,5 @@ service FrontendService {
 
     TStreamLoadPutResult streamLoadPut(1: TStreamLoadPutRequest request)
 
+    Status.TStatus snapshotLoaderReport(1: TSnapshotLoaderReportRequest 
request)
 }


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to