From 47337ea8b78bc3efe2cad3cdd5d2a3c659da0ac2 Mon Sep 17 00:00:00 2001 From: Zhen Ye Date: Fri, 1 Nov 2024 18:12:22 +0800 Subject: [PATCH] fix: crash when startup if the milvus volume is on-operation concurrently (#37313) issue: #37311 pr: #37312 Signed-off-by: chyezh --- internal/core/src/storage/LocalChunkManager.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/internal/core/src/storage/LocalChunkManager.cpp b/internal/core/src/storage/LocalChunkManager.cpp index 2b6870cd11893..7d093c7720d40 100644 --- a/internal/core/src/storage/LocalChunkManager.cpp +++ b/internal/core/src/storage/LocalChunkManager.cpp @@ -15,6 +15,7 @@ // limitations under the License. #include "LocalChunkManager.h" +#include "log/Log.h" #include #include @@ -232,7 +233,17 @@ LocalChunkManager::GetSizeOfDir(const std::string& dir) { it != v.end(); ++it) { if (boost::filesystem::is_regular_file(it->path())) { - total_file_size += boost::filesystem::file_size(it->path()); + boost::system::error_code ec; + auto file_size = boost::filesystem::file_size(it->path(), ec); + if (ec) { + // The file may be removed concurrently by other threads. + // So the file size cannot be obtained, just ignore it. + LOG_INFO("size of file {} cannot be obtained with error: {}", + it->path().string(), + ec.message()); + continue; + } + total_file_size += file_size; } if (boost::filesystem::is_directory(it->path())) { total_file_size += GetSizeOfDir(it->path().string());