yiguolei commented on a change in pull request #567: Add publish version task
URL: https://github.com/apache/incubator-doris/pull/567#discussion_r249676407
 
 

 ##########
 File path: be/src/olap/storage_engine.cpp
 ##########
 @@ -1002,4 +956,60 @@ OLAPStatus StorageEngine::load_header(
     return res;
 }
 
+
+OLAPStatus StorageEngine::execute_task(EngineTask* task) {
+    // 1. add wlock to related tablets
+    // 2. do prepare work
+    // 3. release wlock
+    {
+        vector<TabletInfo> tablet_infos;
+        task->get_related_tablets(&tablet_infos);
+        sort(tablet_infos.begin(), tablet_infos.end());
+        for (TabletInfo& tablet_info : tablet_infos) {
+            TabletSharedPtr tablet = TabletManager::instance()->get_tablet(
+                tablet_info.tablet_id, tablet_info.schema_hash, false);
+            tablet->obtain_header_wrlock();
+        }
+        // add write lock to all related tablets
+        OLAPStatus prepare_status = task->prepare();
+        for (TabletInfo& tablet_info : tablet_infos) {
+            TabletSharedPtr tablet = TabletManager::instance()->get_tablet(
+                tablet_info.tablet_id, tablet_info.schema_hash, false);
+            tablet->release_header_lock();
+        }
+        if (prepare_status != OLAP_SUCCESS) {
+            return prepare_status;
+        }
+    }
+
+    // do execute work without lock
+    OLAPStatus exec_status = task->execute();
+    if (exec_status != OLAP_SUCCESS) {
+        return exec_status;
+    }
+    
+    // 1. add wlock to related tablets
+    // 2. do finish work
+    // 3. release wlock
+    {
+        vector<TabletInfo> tablet_infos;
 
 Review comment:
   I only need tablet id and schema hash and will sort them by tablet id and 
schema hash

----------------------------------------------------------------
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:
us...@infra.apache.org


With regards,
Apache Git Services

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

Reply via email to