dataroaring commented on code in PR #14231:
URL: https://github.com/apache/doris/pull/14231#discussion_r1021029695


##########
be/src/olap/storage_engine.cpp:
##########
@@ -862,11 +862,13 @@ void StorageEngine::_parse_default_rowset_type() {
 }
 
 void StorageEngine::start_delete_unused_rowset() {
-    std::lock_guard<std::mutex> lock(_gc_mutex);
-    for (auto it = _unused_rowsets.begin(); it != _unused_rowsets.end();) {
-        if (it->second.use_count() != 1) {
-            ++it;
-        } else if (it->second->need_delete_file()) {
+    std::unordered_map<std::string, RowsetSharedPtr> unused_rowsets_copy;
+    {
+        std::lock_guard<std::mutex> lock(_gc_mutex);
+        unused_rowsets_copy = _unused_rowsets;
+    }
+    for (auto it = unused_rowsets_copy.begin(); it != 
unused_rowsets_copy.end(); ++it) {
+        if (it->second.use_count() == 1 && it->second->need_delete_file()) {

Review Comment:
   I am not sure that use_count is at least 2 after 'unused_rowsets_copy = 
_unused_rowsets'.



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