未验证 提交 0710ecec 编写于 作者: G groot 提交者: GitHub

#2373 Build index for small segment waste time on waiting background index thread finish (#2482)

* #2349 Drop collection timeout if too many partitions created on collection
Signed-off-by: Ngroot <yihua.mo@zilliz.com>

* changelog
Signed-off-by: Nyhmo <yihua.mo@zilliz.com>

* #2373 Build index for small segment waste time on waiting background index thread finish
Signed-off-by: Nyhmo <yihua.mo@zilliz.com>
上级 257ea778
...@@ -5,6 +5,7 @@ Please mark all change in change log and use the issue from GitHub ...@@ -5,6 +5,7 @@ Please mark all change in change log and use the issue from GitHub
## Bug ## Bug
- \#2367 Fix inconsistent reading and writing when using mishards - \#2367 Fix inconsistent reading and writing when using mishards
- \#2373 Build index for small segment waste time on waiting background index thread finish
- \#2394 Drop collection timeout if too many partitions created on collection - \#2394 Drop collection timeout if too many partitions created on collection
## Feature ## Feature
......
...@@ -2377,17 +2377,16 @@ DBImpl::WaitCollectionIndexRecursively(const std::shared_ptr<server::Context>& c ...@@ -2377,17 +2377,16 @@ DBImpl::WaitCollectionIndexRecursively(const std::shared_ptr<server::Context>& c
} }
} }
index_req_swn_.Wait_For(std::chrono::seconds(1)); auto ret = index_req_swn_.Wait_For(std::chrono::seconds(1));
// client break the connection, no need to block, check every 1 second // client break the connection, no need to block, check every 1 second
if (context && context->IsConnectionBroken()) { if (context && context->IsConnectionBroken()) {
LOG_ENGINE_DEBUG_ << "Client connection broken, build index in background"; LOG_ENGINE_DEBUG_ << "Client connection broken, build index in background";
break; // just break, not return, continue to update partitions files to to_index break; // just break, not return, continue to update partitions files to to_index
} }
// check to_index files every 5 seconds // check to_index files every 5 seconds or background index thread finished
repeat++; repeat++;
if (repeat % WAIT_BUILD_INDEX_INTERVAL == 0) { if ((ret == std::cv_status::no_timeout) || (repeat % WAIT_BUILD_INDEX_INTERVAL == 0)) {
GetFilesToBuildIndex(collection_id, file_types, files_holder); GetFilesToBuildIndex(collection_id, file_types, files_holder);
++times; ++times;
} }
......
...@@ -310,22 +310,26 @@ class DBImpl : public DB, public server::CacheConfigHandler, public server::Engi ...@@ -310,22 +310,26 @@ class DBImpl : public DB, public server::CacheConfigHandler, public server::Engi
notified_ = false; notified_ = false;
} }
void std::cv_status
Wait_Until(const std::chrono::system_clock::time_point& tm_pint) { Wait_Until(const std::chrono::system_clock::time_point& tm_pint) {
std::unique_lock<std::mutex> lck(mutex_); std::unique_lock<std::mutex> lck(mutex_);
std::cv_status ret = std::cv_status::timeout;
if (!notified_) { if (!notified_) {
cv_.wait_until(lck, tm_pint); ret = cv_.wait_until(lck, tm_pint);
} }
notified_ = false; notified_ = false;
return ret;
} }
void std::cv_status
Wait_For(const std::chrono::system_clock::duration& tm_dur) { Wait_For(const std::chrono::system_clock::duration& tm_dur) {
std::unique_lock<std::mutex> lck(mutex_); std::unique_lock<std::mutex> lck(mutex_);
std::cv_status ret = std::cv_status::timeout;
if (!notified_) { if (!notified_) {
cv_.wait_for(lck, tm_dur); ret = cv_.wait_for(lck, tm_dur);
} }
notified_ = false; notified_ = false;
return ret;
} }
void void
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册