yangzhg commented on code in PR #11959:
URL: https://github.com/apache/doris/pull/11959#discussion_r952225944


##########
be/src/io/cache/file_cache_manager.cpp:
##########
@@ -29,18 +32,110 @@ void FileCacheManager::add_file_cache(const Path& 
cache_path, FileCachePtr file_
 }
 
 void FileCacheManager::remove_file_cache(const Path& cache_path) {
-    std::lock_guard<std::shared_mutex> wrlock(_cache_map_lock);
-    _file_cache_map.erase(cache_path.native());
+    bool cache_path_exist = false;
+    {
+        std::shared_lock<std::shared_mutex> rdlock(_cache_map_lock);
+        if (_file_cache_map.find(cache_path) == _file_cache_map.end()) {
+            bool cache_dir_exist = false;
+            if (global_local_filesystem()->exists(cache_path, 
&cache_dir_exist).ok()) {
+                if (cache_dir_exist) {
+                    Status st = 
global_local_filesystem()->delete_directory(cache_path);
+                    if (!st.ok()) {
+                        LOG(WARNING) << st.to_string();
+                    }
+                }
+            }
+        } else {
+            cache_path_exist = true;
+            _file_cache_map.find(cache_path)->second->clean_all_cache();
+        }
+    }
+    if (cache_path_exist) {
+        std::lock_guard<std::shared_mutex> wrlock(_cache_map_lock);
+        _file_cache_map.erase(cache_path.native());
+    }
 }
 
 void FileCacheManager::clean_timeout_caches() {
     std::shared_lock<std::shared_mutex> rdlock(_cache_map_lock);
     for (std::map<std::string, FileCachePtr>::const_iterator iter = 
_file_cache_map.cbegin();
          iter != _file_cache_map.cend(); ++iter) {
+        if (iter->second == nullptr) {
+            continue;
+        }
         iter->second->clean_timeout_cache();
     }
 }
 
+void FileCacheManager::clean_timeout_file_not_in_mem(const Path& cache_path) {
+    std::shared_lock<std::shared_mutex> rdlock(_cache_map_lock);

Review Comment:
   using `std::string_view` and `emplace_back` maybe better



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