fix: [StorageV2] Make DiskFileManager use fs from context (#44535)

Related to #44534

Datanode shall not use singleton fs after 2.6+. This patch make disk
file manager use filesystem passed by fileManagerContext instead of
errorous singleton one.

---------

Signed-off-by: Congqi Xia <congqi.xia@zilliz.com>
This commit is contained in:
congqixia 2025-09-24 10:12:03 +08:00 committed by GitHub
parent d5255b5eef
commit ea307ea3c9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 17 additions and 8 deletions

View File

@ -22,6 +22,7 @@
#include "index/json_stats/bson_builder.h"
#include "index/InvertedIndexUtil.h"
#include "index/Utils.h"
#include "milvus-storage/filesystem/fs.h"
#include "storage/MmapManager.h"
#include "storage/Util.h"
#include "common/bson_view.h"
@ -76,8 +77,12 @@ JsonKeyStats::JsonKeyStats(const storage::FileManagerContext& ctx,
// TODO: add params to modify batch size and max file size
auto conf = milvus_storage::StorageConfig();
conf.part_size = DEFAULT_PART_UPLOAD_SIZE;
auto trueFs = milvus_storage::ArrowFileSystemSingleton::GetInstance()
.GetArrowFileSystem();
auto trueFs = ctx.fs;
// try singleton if possible
if (!trueFs) {
trueFs = milvus_storage::ArrowFileSystemSingleton::GetInstance()
.GetArrowFileSystem();
}
if (!trueFs) {
ThrowInfo(ErrorCode::UnexpectedError, "Failed to get filesystem");
}

View File

@ -171,9 +171,11 @@ DiskFileManagerImpl::OpenInputStream(const std::string& filename) {
auto local_file_name = GetFileName(filename);
auto remote_file_path = GetRemoteIndexPathV2(local_file_name);
auto fs = milvus_storage::ArrowFileSystemSingleton::GetInstance()
.GetArrowFileSystem();
auto fs = fs_;
if (!fs) {
fs = milvus_storage::ArrowFileSystemSingleton::GetInstance()
.GetArrowFileSystem();
}
auto remote_file = fs->OpenInputFile(remote_file_path);
AssertInfo(remote_file.ok(), "failed to open remote file");
return std::static_pointer_cast<milvus::InputStream>(
@ -186,9 +188,11 @@ DiskFileManagerImpl::OpenOutputStream(const std::string& filename) {
auto local_file_name = GetFileName(filename);
auto remote_file_path = GetRemoteIndexPathV2(local_file_name);
auto fs = milvus_storage::ArrowFileSystemSingleton::GetInstance()
.GetArrowFileSystem();
auto fs = fs_;
if (!fs) {
fs = milvus_storage::ArrowFileSystemSingleton::GetInstance()
.GetArrowFileSystem();
}
auto remote_stream = fs->OpenOutputStream(remote_file_path);
AssertInfo(remote_stream.ok(),
"failed to open remote stream, reason: {}",