This is an automated email from the ASF dual-hosted git repository. pengxiangyu pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/master by this push: new 38530100d8 [fix](localgc) check gc only cache directory (#15238) 38530100d8 is described below commit 38530100d812004d1d5069875ffa7188f31ab27b Author: luozenglin <37725793+luozeng...@users.noreply.github.com> AuthorDate: Fri Dec 23 10:40:55 2022 +0800 [fix](localgc) check gc only cache directory (#15238) --- be/src/io/cache/file_cache_manager.cpp | 3 ++- be/src/olap/rowset/beta_rowset.cpp | 9 +++++++++ be/src/olap/rowset/beta_rowset.h | 2 ++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/be/src/io/cache/file_cache_manager.cpp b/be/src/io/cache/file_cache_manager.cpp index 6d34434190..a49dfcd240 100644 --- a/be/src/io/cache/file_cache_manager.cpp +++ b/be/src/io/cache/file_cache_manager.cpp @@ -22,6 +22,7 @@ #include "io/cache/sub_file_cache.h" #include "io/cache/whole_file_cache.h" #include "io/fs/local_file_system.h" +#include "olap/rowset/beta_rowset.h" #include "olap/storage_engine.h" #include "util/file_utils.h" #include "util/string_util.h" @@ -125,7 +126,7 @@ void FileCacheManager::_gc_unused_file_caches(std::list<FileCachePtr>& result) { for (Path seg_file : seg_file_paths) { std::string seg_filename = seg_file.native(); // check if it is a dir name - if (ends_with(seg_filename, ".dat") || ends_with(seg_filename, "clone")) { + if (!BetaRowset::is_segment_cache_dir(seg_filename)) { continue; } // skip file cache already in memory diff --git a/be/src/olap/rowset/beta_rowset.cpp b/be/src/olap/rowset/beta_rowset.cpp index 8f0bda1bc6..a6a0d29870 100644 --- a/be/src/olap/rowset/beta_rowset.cpp +++ b/be/src/olap/rowset/beta_rowset.cpp @@ -58,6 +58,15 @@ std::string BetaRowset::segment_cache_path(int segment_id) { return fmt::format("{}/{}_{}", _tablet_path, rowset_id().to_string(), segment_id); } +// just check that the format is xxx_segmentid and segmentid is numeric +bool BetaRowset::is_segment_cache_dir(const std::string& cache_dir) { + auto segment_id_pos = cache_dir.find_last_of('_') + 1; + if (segment_id_pos >= cache_dir.size() || segment_id_pos == 0) { + return false; + } + return std::all_of(cache_dir.cbegin() + segment_id_pos, cache_dir.cend(), ::isdigit); +} + std::string BetaRowset::segment_file_path(const std::string& rowset_dir, const RowsetId& rowset_id, int segment_id) { // {rowset_dir}/{schema_hash}/{rowset_id}_{seg_num}.dat diff --git a/be/src/olap/rowset/beta_rowset.h b/be/src/olap/rowset/beta_rowset.h index 8c43a742d2..a1167d2c2c 100644 --- a/be/src/olap/rowset/beta_rowset.h +++ b/be/src/olap/rowset/beta_rowset.h @@ -49,6 +49,8 @@ public: static std::string segment_cache_path(const std::string& rowset_dir, const RowsetId& rowset_id, int segment_id); + static bool is_segment_cache_dir(const std::string& cache_dir); + static std::string segment_file_path(const std::string& rowset_dir, const RowsetId& rowset_id, int segment_id); --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org