diff --git a/CHANGELOG.md b/CHANGELOG.md index 9ddff2a51c..016fd33a5a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -25,6 +25,7 @@ Please mark all change in change log and use the ticket from JIRA. - \#509 - IVF_PQ index build trapped into dead loop caused by invalid params - \#513 - Unittest DELETE_BY_RANGE sometimes failed - \#527 - faiss benchmark not compatible with faiss 1.6.0 +- \#530 - BuildIndex stop when do build index and search simultaneously ## Feature - \#12 - Pure CPU version for Milvus diff --git a/core/src/scheduler/BuildMgr.h b/core/src/scheduler/BuildMgr.h index 805c01aafd..3c466421a0 100644 --- a/core/src/scheduler/BuildMgr.h +++ b/core/src/scheduler/BuildMgr.h @@ -55,6 +55,11 @@ class BuildMgr { } } + int64_t + NumOfAvailable() { + return available_; + } + private: std::int64_t available_; std::mutex mutex_; diff --git a/core/src/scheduler/TaskTable.cpp b/core/src/scheduler/TaskTable.cpp index 425eb0ab06..1bb6525215 100644 --- a/core/src/scheduler/TaskTable.cpp +++ b/core/src/scheduler/TaskTable.cpp @@ -178,7 +178,8 @@ TaskTable::PickToLoad(uint64_t limit) { // if task is a build index task, limit it if (task->Type() == TaskType::BuildIndexTask && task->path().Current() == "cpu") { - if (not BuildMgrInst::GetInstance()->Take()) { + if (BuildMgrInst::GetInstance()->NumOfAvailable() < 1) { + SERVER_LOG_WARNING << "BuildMgr doesnot have available place for building index"; continue; } } diff --git a/core/src/scheduler/resource/Resource.cpp b/core/src/scheduler/resource/Resource.cpp index 8cf03275f7..596d7da468 100644 --- a/core/src/scheduler/resource/Resource.cpp +++ b/core/src/scheduler/resource/Resource.cpp @@ -178,6 +178,10 @@ Resource::loader_function() { if (task_item == nullptr) { break; } + if (task_item->task->Type() == TaskType::BuildIndexTask && name() == "cpu") { + BuildMgrInst::GetInstance()->Take(); + SERVER_LOG_DEBUG << name() << " load BuildIndexTask"; + } LoadFile(task_item->task); task_item->Loaded(); if (task_item->from) { @@ -208,7 +212,6 @@ Resource::executor_function() { if (task_item == nullptr) { break; } - auto start = get_current_timestamp(); Process(task_item->task); auto finish = get_current_timestamp();