chaoyli closed pull request #491: Move push logic to batch load task
URL: https://github.com/apache/incubator-doris/pull/491
 
 
   

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/CMakeLists.txt b/be/src/agent/CMakeLists.txt
index e523a509..8fb9b1ef 100644
--- a/be/src/agent/CMakeLists.txt
+++ b/be/src/agent/CMakeLists.txt
@@ -23,7 +23,6 @@ set(EXECUTABLE_OUTPUT_PATH "${BUILD_DIR}/src/agent")
   
 add_library(Agent STATIC
     agent_server.cpp
-    pusher.cpp
     file_downloader.cpp
     heartbeat_server.cpp
     task_worker_pool.cpp
diff --git a/be/src/agent/pusher.h b/be/src/agent/pusher.h
deleted file mode 100644
index b3010c92..00000000
--- a/be/src/agent/pusher.h
+++ /dev/null
@@ -1,79 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.
-
-#ifndef DORIS_BE_SRC_AGENT_PUSHER_H
-#define DORIS_BE_SRC_AGENT_PUSHER_H
-
-#include <utility>
-#include <vector>
-#include "agent/file_downloader.h"
-#include "agent/status.h"
-#include "gen_cpp/AgentService_types.h"
-#include "gen_cpp/MasterService_types.h"
-#include "olap/olap_common.h"
-#include "olap/olap_define.h"
-
-namespace doris {
-
-const uint32_t MAX_RETRY = 3;
-const uint32_t DEFAULT_DOWNLOAD_TIMEOUT = 3600;
-class StorageEngine;
-
-class Pusher {
-public:
-    explicit Pusher(StorageEngine* engine, const TPushReq& push_req);
-    virtual ~Pusher();
-    
-    // The initial function of pusher
-    virtual AgentStatus init();
-
-    // The process of push data to olap engine
-    //
-    // Output parameters:
-    // * tablet_infos: The info of pushed tablet after push data
-    virtual AgentStatus process(std::vector<TTabletInfo>* tablet_infos);
-
-    // Delete data of specified tablet according to delete conditions,
-    // once delete_data command submit success, deleted data is not visible,
-    // but not actually deleted util delay_delete_time run out.
-    //
-    // @param [in] request specify tablet and delete conditions
-    // @param [out] tablet_info_vec return tablet lastest status, which
-    //              include version info, row count, data size, etc
-    // @return OLAP_SUCCESS if submit delete_data success
-    virtual OLAPStatus delete_data(
-            const TPushReq& request,
-            std::vector<TTabletInfo>* tablet_info_vec);
-
-private:
-    AgentStatus _get_tmp_file_dir(const std::string& root_path, std::string* 
local_path);
-    AgentStatus _download_file();
-    OLAPStatus _push(const TPushReq& request,
-                    std::vector<TTabletInfo>* tablet_info_vec);
-    void _get_file_name_from_path(const std::string& file_path, std::string* 
file_name);
-    
-    bool _is_init = false;
-    TPushReq _push_req;
-    FileDownloader::FileDownloaderParam _downloader_param;
-    StorageEngine* _engine;
-    FileDownloader* _file_downloader;
-    AgentStatus _download_status;
-
-    DISALLOW_COPY_AND_ASSIGN(Pusher);
-};  // class Pusher
-}  // namespace doris
-#endif  // DORIS_BE_SRC_AGENT_SERVICE_PUSHER_H
diff --git a/be/src/agent/task_worker_pool.cpp 
b/be/src/agent/task_worker_pool.cpp
index f2d3e059..a58bb035 100644
--- a/be/src/agent/task_worker_pool.cpp
+++ b/be/src/agent/task_worker_pool.cpp
@@ -31,7 +31,6 @@
 
 #include "boost/filesystem.hpp"
 #include "boost/lexical_cast.hpp"
-#include "agent/pusher.h"
 #include "agent/status.h"
 #include "agent/utils.h"
 #include "gen_cpp/FrontendService.h"
@@ -69,7 +68,6 @@ namespace doris {
 
 const uint32_t DOWNLOAD_FILE_MAX_RETRY = 3;
 const uint32_t TASK_FINISH_MAX_RETRY = 3;
-const uint32_t PUSH_MAX_RETRY = 1;
 const uint32_t PUBLISH_VERSION_MAX_RETRY = 3;
 const uint32_t REPORT_TASK_WORKER_COUNT = 1;
 const uint32_t REPORT_DISK_STATE_WORKER_COUNT = 1;
@@ -716,49 +714,9 @@ void* TaskWorkerPool::_push_worker_thread_callback(void* 
arg_this) {
         LOG(INFO) << "get push task. signature: " << agent_task_req.signature
                   << " user: " << user << " priority: " << priority;
         vector<TTabletInfo> tablet_infos;
-        if (push_req.push_type == TPushType::LOAD || push_req.push_type == 
TPushType::LOAD_DELETE) {
-#ifndef BE_TEST
-            Pusher pusher(worker_pool_this->_env->olap_engine(), push_req);
-            status = pusher.init();
-#else
-            status = worker_pool_this->_pusher->init();
-#endif
-
-            if (status == DORIS_SUCCESS) {
-                uint32_t retry_time = 0;
-                while (retry_time < PUSH_MAX_RETRY) {
-#ifndef BE_TEST
-                    status = pusher.process(&tablet_infos);
-#else
-                    status = worker_pool_this->_pusher->process(&tablet_infos);
-#endif
-                    if (status == DORIS_PUSH_HAD_LOADED) {
-                        OLAP_LOG_WARNING("transaction exists when realtime 
push, "
-                                         "but unfinished, do not report to fe, 
signature: %ld",
-                                         agent_task_req.signature);
-                        break;  // not retry any more
-                    }
-                    // Internal error, need retry
-                    if (status == DORIS_ERROR) {
-                        OLAP_LOG_WARNING("push internal error, need 
retry.signature: %ld",
-                                         agent_task_req.signature);
-                        retry_time += 1;
-                    } else {
-                        break;
-                    }
-                }
-            }
-        } else if (push_req.push_type == TPushType::DELETE) {
-            Pusher pusher(worker_pool_this->_env->olap_engine(), push_req);
-            OLAPStatus delete_data_status = pusher.delete_data(push_req, 
&tablet_infos);
-            if (delete_data_status != OLAPStatus::OLAP_SUCCESS) {
-                OLAP_LOG_WARNING("delete data failed. status: %d, signature: 
%ld",
-                                 delete_data_status, agent_task_req.signature);
-                status = DORIS_ERROR;
-            }
-        } else {
-            status = DORIS_TASK_REQUEST_ERROR;
-        }
+        
+        EngineBatchLoadTask task(push_req, &tablet_infos, 
agent_task_req.signature);
+        status = task.execute();
 
 #ifndef BE_TEST
         if (status == DORIS_PUSH_HAD_LOADED) {
@@ -1010,10 +968,7 @@ void* TaskWorkerPool::_clone_worker_thread_callback(void* 
arg_this) {
         vector<string> error_msgs;
         vector<TTabletInfo> tablet_infos;
         EngineCloneTask engine_task(clone_req, error_msgs, tablet_infos);
-        OLAPStatus exec_status = engine_task.execute();
-        if (exec_status != OLAP_SUCCESS) {
-            status = DORIS_ERROR;
-        }
+        status = engine_task.execute();
         // Return result to fe
         TStatus task_status;
         TFinishTaskRequest finish_task_request;
@@ -1072,7 +1027,7 @@ void* 
TaskWorkerPool::_storage_medium_migrate_worker_thread_callback(void* arg_t
         TStatus task_status;
 
         OLAPStatus res = OLAPStatus::OLAP_SUCCESS;
-        res = worker_pool_this->_env->olap_engine()->storage_medium_migrate(
+        res = SnapshotManager::instance()->storage_medium_migrate(
             storage_medium_migrate_req.tablet_id,
             storage_medium_migrate_req.schema_hash,
             storage_medium_migrate_req.storage_medium);
@@ -1126,10 +1081,9 @@ void* 
TaskWorkerPool::_cancel_delete_data_worker_thread_callback(void* arg_this)
         vector<string> error_msgs;
         TStatus task_status;
 
-        OLAPStatus cancel_delete_data_status = OLAPStatus::OLAP_SUCCESS;
         EngineCancelDeleteTask engine_task(cancel_delete_data_req);
-        cancel_delete_data_status = engine_task.execute();
-        if (cancel_delete_data_status != OLAPStatus::OLAP_SUCCESS) {
+        AgentStatus cancel_delete_data_status = engine_task.execute();
+        if (cancel_delete_data_status != DORIS_SUCCESS) {
             OLAP_LOG_WARNING("cancel delete data failed. statusta: %d, 
signature: %ld",
                              cancel_delete_data_status, 
agent_task_req.signature);
             status_code = TStatusCode::RUNTIME_ERROR;
@@ -1181,15 +1135,14 @@ void* 
TaskWorkerPool::_check_consistency_worker_thread_callback(void* arg_this)
         vector<string> error_msgs;
         TStatus task_status;
 
-        OLAPStatus res = OLAPStatus::OLAP_SUCCESS;
         uint32_t checksum = 0;
         EngineChecksumTask engine_task(check_consistency_req.tablet_id,
                 check_consistency_req.schema_hash,
                 check_consistency_req.version,
                 check_consistency_req.version_hash,
                 &checksum);
-        res = engine_task.execute();
-        if (res != OLAPStatus::OLAP_SUCCESS) {
+        AgentStatus res = engine_task.execute();
+        if (res != DORIS_SUCCESS) {
             OLAP_LOG_WARNING("check consistency failed. status: %d, signature: 
%ld",
                              res, agent_task_req.signature);
             status_code = TStatusCode::RUNTIME_ERROR;
diff --git a/be/src/agent/task_worker_pool.h b/be/src/agent/task_worker_pool.h
index ef5405c0..1500c163 100644
--- a/be/src/agent/task_worker_pool.h
+++ b/be/src/agent/task_worker_pool.h
@@ -26,7 +26,6 @@
 #include <mutex>
 #include <utility>
 #include <vector>
-#include "agent/pusher.h"
 #include "agent/status.h"
 #include "agent/utils.h"
 #include "gen_cpp/AgentService_types.h"
diff --git a/be/src/http/action/checksum_action.cpp 
b/be/src/http/action/checksum_action.cpp
index 6869d485..747aa6fe 100644
--- a/be/src/http/action/checksum_action.cpp
+++ b/be/src/http/action/checksum_action.cpp
@@ -126,11 +126,11 @@ void ChecksumAction::handle(HttpRequest *req) {
 int64_t ChecksumAction::do_checksum(int64_t tablet_id, int64_t version, 
int64_t version_hash,
         int32_t schema_hash, HttpRequest *req) {
 
-    OLAPStatus res = OLAPStatus::OLAP_SUCCESS;
+    AgentStatus res = DORIS_SUCCESS;
     uint32_t checksum;
     EngineChecksumTask engine_task(tablet_id, schema_hash, version, 
version_hash, &checksum);
     res = engine_task.execute();
-    if (res != OLAPStatus::OLAP_SUCCESS) {
+    if (res != DORIS_SUCCESS) {
         LOG(WARNING) << "checksum failed. status: " << res
                      << ", signature: " << tablet_id;
         return -1L;
diff --git a/be/src/olap/CMakeLists.txt b/be/src/olap/CMakeLists.txt
index f0e18335..22a29aec 100644
--- a/be/src/olap/CMakeLists.txt
+++ b/be/src/olap/CMakeLists.txt
@@ -78,4 +78,5 @@ add_library(Olap STATIC
     rowset/alpha_rowset_builder.cpp
     rowset/alpha_rowset_meta.cpp
     task/engine_schema_change_task.cpp
+    task/engine_batch_load_task.cpp
 )
diff --git a/be/src/olap/snapshot_manager.h b/be/src/olap/snapshot_manager.h
index 4b5a486e..a928950b 100644
--- a/be/src/olap/snapshot_manager.h
+++ b/be/src/olap/snapshot_manager.h
@@ -58,6 +58,10 @@ class SnapshotManager {
     // @param snapshot_path [in] 要被释放的snapshot的路径,只包含到ID
     OLAPStatus release_snapshot(const std::string& snapshot_path);
 
+    OLAPStatus storage_medium_migrate(
+                TTabletId tablet_id, TSchemaHash schema_hash,
+                TStorageMedium::type storage_medium);
+                
     static SnapshotManager* instance();
 
 private:
diff --git a/be/src/olap/storage_engine.h b/be/src/olap/storage_engine.h
index ef72d3f2..1b4a6a12 100644
--- a/be/src/olap/storage_engine.h
+++ b/be/src/olap/storage_engine.h
@@ -152,12 +152,6 @@ class StorageEngine {
         return _store_map.size();
     }
 
-    // @brief 迁移数据,从一种存储介质到另一种存储介质
-    OLAPStatus storage_medium_migrate(
-            TTabletId tablet_id,
-            TSchemaHash schema_hash,
-            TStorageMedium::type storage_medium);
-
     void start_delete_unused_index();
 
     void add_unused_index(SegmentGroup* olap_index);
diff --git a/be/src/agent/pusher.cpp 
b/be/src/olap/task/engine_batch_load_task.cpp
similarity index 84%
rename from be/src/agent/pusher.cpp
rename to be/src/olap/task/engine_batch_load_task.cpp
index 8d22e483..1818b0e1 100644
--- a/be/src/agent/pusher.cpp
+++ b/be/src/olap/task/engine_batch_load_task.cpp
@@ -15,7 +15,7 @@
 // specific language governing permissions and limitations
 // under the License.
 
-#include "agent/pusher.h"
+#include "olap/task/engine_batch_load_task.h"
 #include <pthread.h>
 #include <cstdio>
 #include <ctime>
@@ -44,15 +44,54 @@ using std::vector;
 namespace doris {
 
     
-Pusher::Pusher(StorageEngine* engine, const TPushReq& push_req) :
-        _push_req(push_req), _engine(engine) {
+EngineBatchLoadTask::EngineBatchLoadTask(const TPushReq& push_req, 
+    std::vector<TTabletInfo>* tablet_infos, 
+    int64_t signature) :
+        _push_req(push_req), _tablet_infos(tablet_infos), 
_signature(signature) {
     _download_status = DORIS_SUCCESS;
 }
 
-Pusher::~Pusher() {
+EngineBatchLoadTask::~EngineBatchLoadTask() {
 }
 
-AgentStatus Pusher::init() {
+AgentStatus EngineBatchLoadTask::execute() {
+    AgentStatus status = DORIS_SUCCESS;
+    if (_push_req.push_type == TPushType::LOAD || _push_req.push_type == 
TPushType::LOAD_DELETE) {
+        status = _init();
+        if (status == DORIS_SUCCESS) {
+            uint32_t retry_time = 0;
+            while (retry_time < PUSH_MAX_RETRY) {
+                status = _process();
+
+                if (status == DORIS_PUSH_HAD_LOADED) {
+                    OLAP_LOG_WARNING("transaction exists when realtime push, "
+                                        "but unfinished, do not report to fe, 
signature: %ld",
+                                        _signature);
+                    break;  // not retry any more
+                }
+                // Internal error, need retry
+                if (status == DORIS_ERROR) {
+                    OLAP_LOG_WARNING("push internal error, need 
retry.signature: %ld",
+                                        _signature);
+                    retry_time += 1;
+                } else {
+                    break;
+                }
+            }
+        }
+    } else if (_push_req.push_type == TPushType::DELETE) {
+        OLAPStatus delete_data_status = _delete_data(_push_req, _tablet_infos);
+        if (delete_data_status != OLAPStatus::OLAP_SUCCESS) {
+            OLAP_LOG_WARNING("delete data failed. status: %d, signature: %ld",
+                                delete_data_status, _signature);
+            status = DORIS_ERROR;
+        }
+    } else {
+        status = DORIS_TASK_REQUEST_ERROR;
+    }
+}
+
+AgentStatus EngineBatchLoadTask::_init() {
     AgentStatus status = DORIS_SUCCESS;
 
     if (_is_init) {
@@ -111,7 +150,7 @@ AgentStatus Pusher::init() {
 }
 
 // Get replica root path
-AgentStatus Pusher::_get_tmp_file_dir(const string& root_path, string* 
download_path) {
+AgentStatus EngineBatchLoadTask::_get_tmp_file_dir(const string& root_path, 
string* download_path) {
     AgentStatus status = DORIS_SUCCESS;
     *download_path = root_path + DPP_PREFIX;
 
@@ -133,7 +172,7 @@ AgentStatus Pusher::_get_tmp_file_dir(const string& 
root_path, string* download_
     return status;
 }
 
-AgentStatus Pusher::_download_file() {
+AgentStatus EngineBatchLoadTask::_download_file() {
     LOG(INFO) << "begin download file. tablet_id=" << _push_req.tablet_id;
     time_t start = time(NULL);
     AgentStatus status = DORIS_SUCCESS;
@@ -165,13 +204,13 @@ AgentStatus Pusher::_download_file() {
     return status;
 }
 
-void Pusher::_get_file_name_from_path(const string& file_path, string* 
file_name) {
+void EngineBatchLoadTask::_get_file_name_from_path(const string& file_path, 
string* file_name) {
     size_t found = file_path.find_last_of("/\\");
     pthread_t tid = pthread_self();
     *file_name = file_path.substr(found + 1) + "_" + 
boost::lexical_cast<string>(tid);
 }
 
-AgentStatus Pusher::process(vector<TTabletInfo>* tablet_infos) {
+AgentStatus EngineBatchLoadTask::_process() {
     AgentStatus status = DORIS_SUCCESS;
 
     if (!_is_init) {
@@ -256,7 +295,7 @@ AgentStatus Pusher::process(vector<TTabletInfo>* 
tablet_infos) {
     if (status == DORIS_SUCCESS) {
         // Load delta file
         time_t push_begin = time(NULL);
-        OLAPStatus push_status = _push(_push_req, tablet_infos);
+        OLAPStatus push_status = _push(_push_req, _tablet_infos);
         time_t push_finish = time(NULL);
         LOG(INFO) << "Push finish, cost time: " << (push_finish - push_begin);
         if (push_status == 
OLAPStatus::OLAP_ERR_PUSH_TRANSACTION_ALREADY_EXIST) {
@@ -278,7 +317,7 @@ AgentStatus Pusher::process(vector<TTabletInfo>* 
tablet_infos) {
     return status;
 }
 
-OLAPStatus Pusher::_push(const TPushReq& request,
+OLAPStatus EngineBatchLoadTask::_push(const TPushReq& request,
                         vector<TTabletInfo>* tablet_info_vec) {
     OLAPStatus res = OLAP_SUCCESS;
     LOG(INFO) << "begin to process push. tablet_id=" << request.tablet_id
@@ -334,7 +373,7 @@ OLAPStatus Pusher::_push(const TPushReq& request,
 }
 
 
-OLAPStatus Pusher::delete_data(
+OLAPStatus EngineBatchLoadTask::_delete_data(
         const TPushReq& request,
         vector<TTabletInfo>* tablet_info_vec) {
     LOG(INFO) << "begin to process delete data. request=" << 
ThriftDebugString(request);
diff --git a/be/src/olap/task/engine_batch_load_task.h 
b/be/src/olap/task/engine_batch_load_task.h
index e69de29b..2e84ac42 100644
--- a/be/src/olap/task/engine_batch_load_task.h
+++ b/be/src/olap/task/engine_batch_load_task.h
@@ -0,0 +1,84 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#ifndef DORIS_BE_SRC_OLAP_TASK_ENGINE_BATCH_LOAD_TASK_H
+#define DORIS_BE_SRC_OLAP_TASK_ENGINE_BATCH_LOAD_TASK_H
+
+#include <utility>
+#include <vector>
+#include "agent/file_downloader.h"
+#include "agent/status.h"
+#include "gen_cpp/AgentService_types.h"
+#include "gen_cpp/MasterService_types.h"
+#include "olap/olap_common.h"
+#include "olap/olap_define.h"
+#include "olap/task/engine_task.h"
+
+using namespace std;
+
+namespace doris {
+
+const uint32_t PUSH_MAX_RETRY = 1;
+const uint32_t MAX_RETRY = 3;
+const uint32_t DEFAULT_DOWNLOAD_TIMEOUT = 3600;
+class StorageEngine;
+
+class EngineBatchLoadTask : public EngineTask{
+public:
+    EngineBatchLoadTask(const TPushReq& push_req, std::vector<TTabletInfo>* 
tablet_infos, int64_t signature);
+    virtual ~EngineBatchLoadTask();
+    
+    virtual AgentStatus execute();
+
+private:
+    // The initial function of pusher
+    virtual AgentStatus _init();
+
+    // The process of push data to olap engine
+    //
+    // Output parameters:
+    // * tablet_infos: The info of pushed tablet after push data
+    virtual AgentStatus _process();
+
+    // Delete data of specified tablet according to delete conditions,
+    // once delete_data command submit success, deleted data is not visible,
+    // but not actually deleted util delay_delete_time run out.
+    //
+    // @param [in] request specify tablet and delete conditions
+    // @param [out] tablet_info_vec return tablet lastest status, which
+    //              include version info, row count, data size, etc
+    // @return OLAP_SUCCESS if submit delete_data success
+    virtual OLAPStatus _delete_data(const TPushReq& request,
+        vector<TTabletInfo>* tablet_info_vec);
+
+    AgentStatus _get_tmp_file_dir(const std::string& root_path, std::string* 
local_path);
+    AgentStatus _download_file();
+    OLAPStatus _push(const TPushReq& request,
+                    std::vector<TTabletInfo>* tablet_info_vec);
+    void _get_file_name_from_path(const std::string& file_path, std::string* 
file_name);
+    
+    bool _is_init = false;
+    const TPushReq& _push_req;
+    std::vector<TTabletInfo>* _tablet_infos;
+    FileDownloader::FileDownloaderParam _downloader_param;
+    FileDownloader* _file_downloader;
+    AgentStatus _download_status;
+
+    int64_t _signature;
+};  // class Pusher
+}  // namespace doris
+#endif  // DORIS_BE_SRC_OLAP_TASK_ENGINE_BATCH_LOAD_TASK_H
diff --git a/be/src/olap/task/engine_cancel_delete_task.cpp 
b/be/src/olap/task/engine_cancel_delete_task.cpp
index 5bd4489b..240dbe30 100644
--- a/be/src/olap/task/engine_cancel_delete_task.cpp
+++ b/be/src/olap/task/engine_cancel_delete_task.cpp
@@ -23,8 +23,13 @@ EngineCancelDeleteTask(const TCancelDeleteDataReq& 
request):_request(request) {
 
 }
 
-OLAPStatus EngineCancelDeleteTask::execute() {
-    return _cancel_delete();
+AgentStatus EngineCancelDeleteTask::execute() {
+    OLAPStatus res =  _cancel_delete();
+    if (res != OLAP_SUCCESS) {
+        return DORIS_ERROR;
+    } else {
+        return DORIS_SUCCESS;
+    }
 } // execute
 
 OLAPStatus EngineCancelDeleteTask::_cancel_delete() {
diff --git a/be/src/olap/task/engine_cancel_delete_task.h 
b/be/src/olap/task/engine_cancel_delete_task.h
index c57bf684..10e340e7 100644
--- a/be/src/olap/task/engine_cancel_delete_task.h
+++ b/be/src/olap/task/engine_cancel_delete_task.h
@@ -29,7 +29,7 @@ namespace doris {
 class EngineCancelDeleteTask : public EngineTask {
 
 public:
-    virtual OLAPStatus execute();
+    virtual AgentStatus execute();
 
 public:
     EngineCancelDeleteTask(const TCancelDeleteDataReq& request);
@@ -39,7 +39,7 @@ class EngineCancelDeleteTask : public EngineTask {
     OLAPStatus _cancel_delete(const TCancelDeleteDataReq& request);
 
 private:
-    TCancelDeleteDataReq& _request;
+    const TCancelDeleteDataReq& _request;
 
 }; // EngineTask
 
diff --git a/be/src/olap/task/engine_checksum_task.cpp 
b/be/src/olap/task/engine_checksum_task.cpp
index 57bd38d2..76c289c1 100644
--- a/be/src/olap/task/engine_checksum_task.cpp
+++ b/be/src/olap/task/engine_checksum_task.cpp
@@ -29,8 +29,13 @@ EngineChecksumTask(TTabletId tablet_id, TSchemaHash 
schema_hash,
 
 }
 
-OLAPStatus EngineChecksumTask::execute() {
-    return _compute_checksum();
+AgentStatus EngineChecksumTask::execute() {
+    OLAPStatus res = _compute_checksum();
+    if (res != OLAP_SUCCESS) {
+        return DORIS_ERROR;
+    } else {
+        return DORIS_SUCCESS;
+    }
 } // execute
 
 
diff --git a/be/src/olap/task/engine_checksum_task.h 
b/be/src/olap/task/engine_checksum_task.h
index 9a114435..cfec30cd 100644
--- a/be/src/olap/task/engine_checksum_task.h
+++ b/be/src/olap/task/engine_checksum_task.h
@@ -29,7 +29,7 @@ namespace doris {
 class EngineChecksumTask : public EngineTask {
 
 public:
-    virtual OLAPStatus execute();
+    virtual AgentStatus execute();
 
 public:
     EngineChecksumTask(TTabletId tablet_id, TSchemaHash schema_hash, 
diff --git a/be/src/olap/task/engine_clone_task.cpp 
b/be/src/olap/task/engine_clone_task.cpp
index 563f786a..7dc003c5 100644
--- a/be/src/olap/task/engine_clone_task.cpp
+++ b/be/src/olap/task/engine_clone_task.cpp
@@ -24,7 +24,8 @@ EngineCloneTask(TCloneReq& _clone_req, vector<string>& 
error_msgs) :
     _error_msgs(error_msgs), 
     _tablet_infos(tablet_infos) {}
 
-OLAPStatus EngineCloneTask::execute() {
+AgentStatus EngineCloneTask::execute() {
+    AgentStatus status = DORIS_SUCCESS;
     string src_file_path;
     TBackend src_host;
     // Check local tablet exist or not
@@ -204,6 +205,7 @@ OLAPStatus EngineCloneTask::execute() {
             _tablet_infos.push_back(tablet_info);
         }
     }
+    return status;
 }
 
 string EngineCloneTask::_get_info_before_incremental_clone(TabletSharedPtr 
tablet,
diff --git a/be/src/olap/task/engine_clone_task.h 
b/be/src/olap/task/engine_clone_task.h
index 9f598ff9..b83483a2 100644
--- a/be/src/olap/task/engine_clone_task.h
+++ b/be/src/olap/task/engine_clone_task.h
@@ -29,7 +29,7 @@ namespace doris {
 class EngineCloneTask : public EngineTask {
 
 public:
-    virtual OLAPStatus execute();
+    virtual AgentStatus execute();
 
 public:
     EngineCloneTask(TCloneReq& _clone_req, vector<string>& error_msgs, 
vector<TTabletInfo> tablet_infos);
@@ -54,7 +54,7 @@ class EngineCloneTask : public EngineTask {
     OLAPStatus _clone_full_data(TabletSharedPtr tablet, TabletMeta& 
clone_header);
 
 private:
-    TCloneReq& _clone_req;
+    const TCloneReq& _clone_req;
     vector<string>& _error_msgs;
     vector<TTabletInfo> _tablet_infos;
 }; // EngineTask
diff --git a/be/src/olap/task/engine_schema_change_task.cpp 
b/be/src/olap/task/engine_schema_change_task.cpp
index fad66aa6..ebfc5034 100644
--- a/be/src/olap/task/engine_schema_change_task.cpp
+++ b/be/src/olap/task/engine_schema_change_task.cpp
@@ -17,16 +17,18 @@
 
 #include "olap/task/engine_schema_change_task.h"
 
+#include "olap/schema_change.h"
+
 namespace doris {
 
-EngineSchemaChangeTask(const TAlterTabletReq& alter_tablet_request, 
+EngineSchemaChangeTask::EngineSchemaChangeTask(const TAlterTabletReq& 
alter_tablet_request, 
         int64_t signature):
         _alter_tablet_req(alter_tablet_request),
         _signature(signature) {
 
 }
 
-OLAPStatus EngineSchemaChangeTask::execute() {
+AgentStatus EngineSchemaChangeTask::execute() {
     OLAPStatus status = OLAP_SUCCESS;
     TTabletId base_tablet_id = _alter_tablet_req.base_tablet_id;
     TSchemaHash base_schema_hash = _alter_tablet_req.base_schema_hash;
@@ -80,7 +82,12 @@ OLAPStatus EngineSchemaChangeTask::execute() {
             }
         }
     }
-    return status;
+
+    if (status != OLAP_SUCCESS) {
+        return DORIS_ERROR;
+    } else {
+        return DORIS_SUCCESS;
+    }
 } // execute
 
 OLAPStatus EngineSchemaChangeTask::_create_rollup_tablet(const 
TAlterTabletReq& request) {
diff --git a/be/src/olap/task/engine_schema_change_task.h 
b/be/src/olap/task/engine_schema_change_task.h
index 0ab2ad5e..5a30ef1f 100644
--- a/be/src/olap/task/engine_schema_change_task.h
+++ b/be/src/olap/task/engine_schema_change_task.h
@@ -29,7 +29,7 @@ namespace doris {
 class EngineSchemaChangeTask : public EngineTask {
 
 public:
-    virtual OLAPStatus execute();
+    virtual AgentStatus execute();
 
 public:
     EngineSchemaChangeTask(const TAlterTabletReq& alter_tablet_request, 
int64_t signature);
@@ -58,7 +58,7 @@ class EngineSchemaChangeTask : public EngineTask {
     OLAPStatus _schema_change(const TAlterTabletReq& request);
 
 private:
-    TAlterTabletReq& _alter_tablet_req;
+    const TAlterTabletReq& _alter_tablet_req;
     int64_t _signature;
 
 }; // EngineTask
diff --git a/be/src/olap/task/engine_task.h b/be/src/olap/task/engine_task.h
index 3ba052df..6fc39122 100644
--- a/be/src/olap/task/engine_task.h
+++ b/be/src/olap/task/engine_task.h
@@ -18,7 +18,13 @@
 #ifndef DORIS_BE_SRC_OLAP_TASK_ENGINE_TASK_H
 #define DORIS_BE_SRC_OLAP_TASK_ENGINE_TASK_H
 
+#include "agent/status.h"
+#include "olap/olap_common.h"
 #include "olap/olap_define.h"
+#include "olap/storage_engine.h"
+#include "olap/tablet_manager.h"
+#include "olap/txn_manager.h"
+#include "util/doris_metrics.h"
 
 namespace doris {
 
@@ -27,10 +33,11 @@ namespace doris {
 class EngineTask {
 
 public:
-    virtual OLAPStatus prepare() { return OLAP_SUCCESS; }
-    virtual OLAPStatus execute() { return OLAP_SUCCESS; }
-    virtual OLAPStatus finish() { return OLAP_SUCCESS; }
-    virtual OLAPStatus clean() { return OLAP_SUCCESS; }
+    // use agent_status not olap_status, because the task is very close to 
engine
+    virtual AgentStatus prepare() { return DORIS_SUCCESS; }
+    virtual AgentStatus execute() { return DORIS_SUCCESS; }
+    virtual AgentStatus finish() { return DORIS_SUCCESS; }
+    virtual AgentStatus clean() { return DORIS_SUCCESS; }
 }; // EngineTask
 
 } // doris
diff --git a/be/src/olap/txn_manager.cpp b/be/src/olap/txn_manager.cpp
index 3299e665..2d201edc 100644
--- a/be/src/olap/txn_manager.cpp
+++ b/be/src/olap/txn_manager.cpp
@@ -178,12 +178,11 @@ void TxnManager::get_txn_related_tablets(const 
TTransactionId transaction_id,
     // get tablets in this transaction
     pair<int64_t, int64_t> key(partition_id, transaction_id);
 
-    _txn_map_lock.rdlock();
+    ReadLock rdlock(&_txn_map_lock);
     auto it = _txn_tablet_map.find(key);
     if (it == _txn_tablet_map.end()) {
         OLAP_LOG_WARNING("could not find tablet for [partition_id=%ld 
transaction_id=%ld]",
                             partition_id, transaction_id);
-        _txn_map_lock.unlock();
         return;
     }
     std::map<TabletInfo, std::pair<PUniqueId, RowsetSharedPtr>> load_info_map 
= it->second;
@@ -193,10 +192,10 @@ void TxnManager::get_txn_related_tablets(const 
TTransactionId transaction_id,
         const TabletInfo& tablet_info = load_info.first;
         tablet_infos->push_back(tablet_info);
         if (rowset_infos != NULL) {
-            rowset_infos->push_back(load_info.second);
+            // TODO(ygl) check rowsetptr is null?
+            rowset_infos->push_back(load_info.second.second);
         }
     }
-    _txn_map_lock.unlock();
 }
                                 
 
diff --git a/be/test/agent/mock_pusher.h b/be/test/agent/mock_pusher.h
index ff10607d..a2ff7360 100644
--- a/be/test/agent/mock_pusher.h
+++ b/be/test/agent/mock_pusher.h
@@ -19,7 +19,6 @@
 #define DORIS_BE_SRC_AGENT_MOCK_MOCK_PUSHER_H
 
 #include "gmock/gmock.h"
-#include "agent/pusher.h"
 
 namespace doris {
 
diff --git a/be/test/agent/pusher_test.cpp b/be/test/agent/pusher_test.cpp
index ebb13939..02189018 100644
--- a/be/test/agent/pusher_test.cpp
+++ b/be/test/agent/pusher_test.cpp
@@ -22,7 +22,6 @@
 #include "gmock/gmock.h"
 #include "agent/mock_file_downloader.h"
 #include "agent/mock_utils.h"
-#include "agent/pusher.h"
 #include "olap/mock_command_executor.h"
 #include "olap/olap_define.h"
 #include "olap/tablet.h"
diff --git a/be/test/agent/task_worker_pool_test.cpp 
b/be/test/agent/task_worker_pool_test.cpp
index 9cf694da..9c36aec6 100644
--- a/be/test/agent/task_worker_pool_test.cpp
+++ b/be/test/agent/task_worker_pool_test.cpp
@@ -24,7 +24,6 @@
 #include "gmock/gmock.h"
 #include "agent/file_downloader.h"
 #include "agent/mock_file_downloader.h"
-#include "agent/mock_pusher.h"
 #include "agent/mock_utils.h"
 #include "agent/mock_task_worker_pool.h"
 #include "agent/task_worker_pool.h"


 

----------------------------------------------------------------
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