This is an automated email from the ASF dual-hosted git repository. ashingau 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 c004fe47f83 [opt](file cache) set failed_if_exists=true when create the cache directory (#35096) c004fe47f83 is described below commit c004fe47f837fa546c594e199d43f2e76a34bc9e Author: Ashin Gau <ashin...@users.noreply.github.com> AuthorDate: Wed May 22 07:49:13 2024 +0800 [opt](file cache) set failed_if_exists=true when create the cache directory (#35096) follow up: #34935 There are many segment files for a cache remote file, so the cached directory will create many times. Therefore, we should call `fs->create_directory(dir, failed_if_exists=false)` instead of `fs->create_directory(dir, failed_if_exists=true)`. When `failed_if_exists=true`, the next line `if (!st.ok() && !st.is<ErrorCode::ALREADY_EXIST>())` try to prevent the `ALREADY_EXIST` errors. --- be/src/common/status.h | 2 -- be/src/io/cache/fs_file_cache_storage.cpp | 2 +- be/src/io/fs/local_file_system.cpp | 20 ++++++++++---------- 3 files changed, 11 insertions(+), 13 deletions(-) diff --git a/be/src/common/status.h b/be/src/common/status.h index 043eddd3229..99b591639e9 100644 --- a/be/src/common/status.h +++ b/be/src/common/status.h @@ -412,7 +412,6 @@ public: if (stacktrace && ErrorCode::error_states[abs(code)].stacktrace) { // Delete the first one frame pointers, which are inside the status.h status._err_msg->_stack = get_stack_trace(1); - LOG(WARNING) << "meet error status: " << status; // may print too many stacks. } #endif return status; @@ -431,7 +430,6 @@ public: #ifdef ENABLE_STACKTRACE if (stacktrace && ErrorCode::error_states[abs(code)].stacktrace) { status._err_msg->_stack = get_stack_trace(1); - LOG(WARNING) << "meet error status: " << status; // may print too many stacks. } #endif return status; diff --git a/be/src/io/cache/fs_file_cache_storage.cpp b/be/src/io/cache/fs_file_cache_storage.cpp index 18c26fa05d4..c66c7351644 100644 --- a/be/src/io/cache/fs_file_cache_storage.cpp +++ b/be/src/io/cache/fs_file_cache_storage.cpp @@ -118,7 +118,7 @@ Status FSFileCacheStorage::append(const FileCacheKey& key, const Slice& value) { writer = iter->second.get(); } else { std::string dir = get_path_in_local_cache(key.hash, key.meta.expiration_time); - auto st = fs->create_directory(dir, true); + auto st = fs->create_directory(dir, false); if (!st.ok() && !st.is<ErrorCode::ALREADY_EXIST>()) { return st; } diff --git a/be/src/io/fs/local_file_system.cpp b/be/src/io/fs/local_file_system.cpp index d7b0cce14ff..9620674d2e9 100644 --- a/be/src/io/fs/local_file_system.cpp +++ b/be/src/io/fs/local_file_system.cpp @@ -93,17 +93,17 @@ Status LocalFileSystem::open_file_impl(const Path& file, FileReaderSPtr* reader, } Status LocalFileSystem::create_directory_impl(const Path& dir, bool failed_if_exists) { - if (failed_if_exists) { - bool exists = true; - RETURN_IF_ERROR(exists_impl(dir, &exists)); - if (exists) { - return Status::AlreadyExist("failed to create {}, already exists", dir.native()); - } + bool exists = true; + RETURN_IF_ERROR(exists_impl(dir, &exists)); + if (exists && failed_if_exists) { + return Status::AlreadyExist("failed to create {}, already exists", dir.native()); } - std::error_code ec; - std::filesystem::create_directories(dir, ec); - if (ec) { - return localfs_error(ec, fmt::format("failed to create {}", dir.native())); + if (!exists) { + std::error_code ec; + std::filesystem::create_directories(dir, ec); + if (ec) { + return localfs_error(ec, fmt::format("failed to create {}", dir.native())); + } } return Status::OK(); } --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org