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


##########
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;
                   if (tablet_path is still exist) {
                         if (config.clone_force_drop_old_path)  {
                                   delete tablet_path;
                         }
                  } 
           }   else {
                  delete 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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


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

Reply via email to