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


##########
be/src/olap/tablet_manager.cpp:
##########
@@ -1040,32 +1028,28 @@ Status 
TabletManager::build_all_report_tablets_info(std::map<TTabletId, TTablet>
 }
 
 Status TabletManager::start_trash_sweep() {
-    SCOPED_CONSUME_MEM_TRACKER(_mem_tracker);
-    {
-        for_each_tablet(
-                [](const TabletSharedPtr& tablet) { 
tablet->delete_expired_stale_rowset(); },
-                filter_all_tablets);
+    std::unique_lock<std::mutex> lock(_gc_tablets_lock, std::defer_lock);
+    if (!lock.try_lock()) {
+        return;
     }
 
+    SCOPED_CONSUME_MEM_TRACKER(_mem_tracker);
+    for_each_tablet([](const TabletSharedPtr& tablet) { 
tablet->delete_expired_stale_rowset(); },
+                    filter_all_tablets);
+
     int32_t clean_num = 0;
     do {
 #ifndef BE_TEST
         sleep(1);
 #endif
         clean_num = 0;
-        // should get write lock here, because it will remove tablet from 
shut_down_tablets
-        // and get tablet will access shut_down_tablets
+        size_t tablet_num = 0;
         {
-            std::lock_guard<std::shared_mutex> wrlock1(_shutdown_tablets_lock);
-            std::lock_guard<std::shared_mutex> 
wrlock2(_shutdown_deleting_tablets_lock);
-            for (const auto& tablet : _shutdown_tablets) {
-                _shutdown_deleting_tablets.push_back(tablet);
-            }
-            _shutdown_tablets.clear();
+            std::shared_lock rdlock(_shutdown_tablets_lock);
+            tablet_num = _shutdown_tablets.size();
         }
-        std::lock_guard<std::shared_mutex> 
wrlock(_shutdown_deleting_tablets_lock);
-        auto it = _shutdown_deleting_tablets.begin();
-        while (it != _shutdown_deleting_tablets.end()) {
+        auto it = _shutdown_tablets.begin();

Review Comment:
   update



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