yujun777 commented on code in PR #34889:
URL: https://github.com/apache/doris/pull/34889#discussion_r1618612066


##########
be/src/olap/tablet_manager.cpp:
##########
@@ -1060,7 +1060,74 @@ void 
TabletManager::build_all_report_tablets_info(std::map<TTabletId, TTablet>*
     LOG(INFO) << "success to build all report tablets info. tablet_count=" << 
tablets_info->size();
 }
 
+Status TabletManager::try_move_to_trash(TTabletId tablet_id, TSchemaHash 
schema_hash,
+                                        const io::Path& tablet_path) {
+    TabletSharedPtr tablet = nullptr;

Review Comment:
   use vector<tablet>  because the maybe multiple tablets with the same 
tablet_id、schema_hash、data_dir.



##########
be/src/olap/tablet_manager.cpp:
##########
@@ -1060,7 +1060,74 @@ void 
TabletManager::build_all_report_tablets_info(std::map<TTabletId, TTablet>*
     LOG(INFO) << "success to build all report tablets info. tablet_count=" << 
tablets_info->size();
 }
 
+Status TabletManager::try_move_to_trash(TTabletId tablet_id, TSchemaHash 
schema_hash,
+                                        const io::Path& tablet_path) {
+    TabletSharedPtr tablet = nullptr;
+    {
+        std::lock_guard<std::shared_mutex> wrdlock(_shutdown_tablets_lock);
+        for (auto it = _shutdown_tablets.begin(); it != 
_shutdown_tablets.end(); it++) {
+            if ((*it)->tablet_id() == tablet_id && (*it)->schema_hash() == 
schema_hash) {
+                if (it->use_count() > 1) {
+                    // clone failed
+                    LOG(INFO) << "tablet still in use, tablet_id=" << tablet_id
+                              << " schema_hash=" << schema_hash;
+                    return Status::Error<INVALID_TABLET_STATE>(
+                            "cant move shutdown tablet to tablet: {}, hash: 
{}, path: {}",
+                            tablet_id, schema_hash, tablet_path.string());
+                } else {
+                    tablet = *it;
+                    _shutdown_tablets.remove(*it);
+                }
+                break;
+            }
+        }
+    }
+
+    if (tablet != nullptr) {
+        bool ok = _move_tablet_to_trash(tablet);
+        if (!ok) {
+            std::lock_guard<std::shared_mutex> wrdlock(_shutdown_tablets_lock);
+            _shutdown_tablets.push_back(tablet);
+        }
+        return Status::OK();
+
+    } else {

Review Comment:
   ```
   delete else,  then always execute code:
   
   if (exists tablet_path) {
           if (exists tablet_meta) {
                   wait 20s  (maybe clean trash thread is running)  then check 
exists tablet_path;
           }   else {
                  delete tablet_path  
           }
   }
   ```



##########
be/src/olap/tablet_manager.cpp:
##########
@@ -1060,7 +1060,74 @@ void 
TabletManager::build_all_report_tablets_info(std::map<TTabletId, TTablet>*
     LOG(INFO) << "success to build all report tablets info. tablet_count=" << 
tablets_info->size();
 }
 
+Status TabletManager::try_move_to_trash(TTabletId tablet_id, TSchemaHash 
schema_hash,
+                                        const io::Path& tablet_path) {
+    TabletSharedPtr tablet = nullptr;
+    {
+        std::lock_guard<std::shared_mutex> wrdlock(_shutdown_tablets_lock);
+        for (auto it = _shutdown_tablets.begin(); it != 
_shutdown_tablets.end(); it++) {
+            if ((*it)->tablet_id() == tablet_id && (*it)->schema_hash() == 
schema_hash) {

Review Comment:
   add check it->tablet_path() == tablet_path



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

To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


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

Reply via email to