fix: [2.4]Throw an exception after all the threads in thread pool finished (#32810) (#33314)

issue: #32487
master pr: #32810

Signed-off-by: Cai Zhang <cai.zhang@zilliz.com>
This commit is contained in:
cai.zhang 2024-05-23 17:55:40 +08:00 committed by GitHub
parent ec33024637
commit ef10d15658
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -575,11 +575,22 @@ GetObjectData(std::shared_ptr<milvus_storage::Space> space,
}
std::vector<FieldDataPtr> datas;
for (int i = 0; i < futures.size(); ++i) {
auto res = futures[i].get();
datas.emplace_back(res->GetFieldData());
std::exception_ptr first_exception = nullptr;
for (auto& future : futures) {
try {
auto res = future.get();
datas.emplace_back(res->GetFieldData());
} catch (...) {
if (!first_exception) {
first_exception = std::current_exception();
}
}
}
ReleaseArrowUnused();
if (first_exception) {
std::rethrow_exception(first_exception);
}
return datas;
}
@ -612,12 +623,22 @@ PutIndexData(ChunkManager* remote_chunk_manager,
}
std::map<std::string, int64_t> remote_paths_to_size;
std::exception_ptr first_exception = nullptr;
for (auto& future : futures) {
auto res = future.get();
remote_paths_to_size[res.first] = res.second;
try {
auto res = future.get();
remote_paths_to_size[res.first] = res.second;
} catch (...) {
if (!first_exception) {
first_exception = std::current_exception();
}
}
}
ReleaseArrowUnused();
if (first_exception) {
std::rethrow_exception(first_exception);
}
ReleaseArrowUnused();
return remote_paths_to_size;
}
@ -650,12 +671,22 @@ PutIndexData(std::shared_ptr<milvus_storage::Space> space,
}
std::map<std::string, int64_t> remote_paths_to_size;
std::exception_ptr first_exception = nullptr;
for (auto& future : futures) {
auto res = future.get();
remote_paths_to_size[res.first] = res.second;
try {
auto res = future.get();
remote_paths_to_size[res.first] = res.second;
} catch (...) {
if (!first_exception) {
first_exception = std::current_exception();
}
}
}
ReleaseArrowUnused();
if (first_exception) {
std::rethrow_exception(first_exception);
}
ReleaseArrowUnused();
return remote_paths_to_size;
}