Merge branch 'branch-0.5.0' into 'branch-0.5.0'

MS-611 Add resources validity check in ResourceMgr

See merge request megasearch/milvus!663

Former-commit-id: 23765cd27ce07bd0f74373800ffb9e91c9293a67
This commit is contained in:
jinhai 2019-10-08 16:27:46 +08:00
commit bfb09cb4fa
3 changed files with 9 additions and 6 deletions

View File

@ -66,12 +66,10 @@ JobMgr::worker_function() {
}
auto tasks = build_task(job);
auto disk_list = res_mgr_->GetDiskResources();
if (!disk_list.empty()) {
if (auto disk = disk_list[0].lock()) {
for (auto& task : tasks) {
disk->task_table().Put(task);
}
// disk resources NEVER be empty.
if (auto disk = res_mgr_->GetDiskResources()[0].lock()) {
for (auto& task : tasks) {
disk->task_table().Put(task);
}
}
}

View File

@ -104,6 +104,10 @@ ResourceMgr::Connect(const std::string& name1, const std::string& name2, Connect
void
ResourceMgr::Clear() {
std::lock_guard<std::mutex> lck(resources_mutex_);
if (running_) {
ENGINE_LOG_ERROR << "ResourceMgr is running, cannot clear.";
return;
}
disk_resources_.clear();
cpu_resources_.clear();
gpu_resources_.clear();

View File

@ -34,6 +34,7 @@ static constexpr size_t PARALLEL_REDUCE_BATCH = 1000;
std::mutex XSearchTask::merge_mutex_;
// TODO(wxyu): remove unused code
// bool
// NeedParallelReduce(uint64_t nq, uint64_t topk) {
// server::ServerConfig &config = server::ServerConfig::GetInstance();