You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@doris.apache.org by GitBox <gi...@apache.org> on 2019/04/17 03:13:48 UTC

[GitHub] [incubator-doris] chaoyli commented on a change in pull request #932: Refactor tablet mgr code

chaoyli commented on a change in pull request #932: Refactor tablet mgr code
URL: https://github.com/apache/incubator-doris/pull/932#discussion_r276063232
 
 

 ##########
 File path: be/src/olap/tablet_manager.cpp
 ##########
 @@ -132,11 +134,44 @@ OLAPStatus TabletManager::add_tablet(TTabletId tablet_id, SchemaHash schema_hash
     bool keep_files = force ? true : false;
     if (force || (new_version > old_version
             || (new_version == old_version && new_time > old_time))) {
-        drop_tablet(tablet_id, schema_hash, keep_files);
-        _tablet_map_lock.wrlock();
+        // check if new tablet's meta is in store and add new tablet's meta to meta store
+        TabletMetaSharedPtr new_tablet_meta(new(nothrow) TabletMeta());
+        if (new_tablet_meta == nullptr) {
+            LOG(WARNING) << "fail to malloc TabletMeta.";
+            return OLAP_ERR_MALLOC_ERROR;
+        }
+        OLAPStatus check_st = TabletMetaManager::get_header(tablet->data_dir(), 
+            tablet->tablet_id(), tablet->schema_hash(), new_tablet_meta);
+        if (check_st == OLAP_ERR_META_KEY_NOT_FOUND) {
+            res = TabletMetaManager::save(tablet->data_dir(), 
+                tablet->tablet_id(), tablet->schema_hash(), tablet->tablet_meta());
+            if (res != OLAP_SUCCESS) {
+                LOG(WARNING) << "failed to save new tablet's meta to meta store" 
+                             << " tablet_id = " << tablet_id
+                             << " schema_hash = " << schema_hash;
+                return res;
+            }
+        }
+        // if the new tablet is fresher than current one
+        // then delete current one and add new one
+        res = _drop_tablet_unlock(tablet_id, schema_hash, keep_files);
+        if (res != OLAP_SUCCESS) {
+            LOG(WARNING) << "failed to drop old tablet when add new tablet"
+                         << " tablet_id = " << tablet_id
+                         << " schema_hash = " << schema_hash;
+            return res;
+        }
+        // Register tablet into StorageEngine, so that we can manage tablet from
+        // the perspective of root path.
+        // Example: unregister all tables when a bad disk found.
+        res = tablet->register_tablet_into_dir();
 
 Review comment:
   Why has you drop tablet, and register tablet into dir?

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


With regards,
Apache Git Services

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