diff --git a/core/src/db/DBImpl.cpp b/core/src/db/DBImpl.cpp index 9529b99ad3..4fe8981e25 100644 --- a/core/src/db/DBImpl.cpp +++ b/core/src/db/DBImpl.cpp @@ -1979,6 +1979,7 @@ DBImpl::BackgroundBuildIndex() { } LOG_ENGINE_DEBUG_ << "Background build index thread finished"; + index_req_swn_.Notify(); // notify CreateIndex check circle } } @@ -2162,7 +2163,7 @@ DBImpl::WaitCollectionIndexRecursively(const std::string& collection_id, const C status = meta_ptr_->UpdateCollectionFilesToIndex(collection_id); } - std::this_thread::sleep_for(std::chrono::seconds(WAIT_BUILD_INDEX_INTERVAL)); + index_req_swn_.Wait_For(std::chrono::seconds(WAIT_BUILD_INDEX_INTERVAL)); GetFilesToBuildIndex(collection_id, file_types, collection_files); ++times; diff --git a/core/src/db/DBImpl.h b/core/src/db/DBImpl.h index 4001326622..c68e8977b6 100644 --- a/core/src/db/DBImpl.h +++ b/core/src/db/DBImpl.h @@ -344,6 +344,7 @@ class DBImpl : public DB, public server::CacheConfigHandler, public server::Engi SimpleWaitNotify swn_index_; SimpleWaitNotify flush_req_swn_; + SimpleWaitNotify index_req_swn_; ThreadPool merge_thread_pool_; std::mutex merge_result_mutex_;