From c604eb59a2480599df4ee6c15ab852350c31e7b3 Mon Sep 17 00:00:00 2001 From: groot Date: Thu, 13 Jun 2019 10:05:08 +0800 Subject: [PATCH 1/2] fix pipeline crash bug Former-commit-id: 55fbac7f92ba19ccb23425f8720b29efd65c5728 --- cpp/src/db/scheduler/SearchTaskQueue.cpp | 35 ++++++++++++------------ 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/cpp/src/db/scheduler/SearchTaskQueue.cpp b/cpp/src/db/scheduler/SearchTaskQueue.cpp index 9cf3199001..101dc818c2 100644 --- a/cpp/src/db/scheduler/SearchTaskQueue.cpp +++ b/cpp/src/db/scheduler/SearchTaskQueue.cpp @@ -21,7 +21,7 @@ void ClusterResult(const std::vector &output_ids, for (auto i = 0; i < nq; i++) { SearchContext::Id2ScoreMap id_score; for (auto k = 0; k < topk; k++) { - uint64_t index = i * nq + k; + uint64_t index = i * topk + k; id_score.push_back(std::make_pair(output_ids[index], output_distence[index])); } result_set.emplace_back(id_score); @@ -125,28 +125,29 @@ bool SearchTask::DoSearch() { try { index_engine_->Search(context->nq(), context->vectors(), inner_k, output_distence.data(), output_ids.data()); + + rc.Record("do search"); + + //step 3: cluster result + SearchContext::ResultSet result_set; + ClusterResult(output_ids, output_distence, context->nq(), inner_k, result_set); + rc.Record("cluster result"); + + //step 4: pick up topk result + TopkResult(result_set, inner_k, context->GetResult()); + rc.Record("reduce topk"); + + //step 5: calculate score between 0 ~ 100 + CalcScore(context->nq(), context->vectors(), index_engine_->Dimension(), context->GetResult(), result_set); + context->GetResult().swap(result_set); + rc.Record("calculate score"); + } catch (std::exception& ex) { SERVER_LOG_ERROR << "SearchTask encounter exception: " << ex.what(); context->IndexSearchDone(index_id_);//mark as done avoid dead lock, even search failed continue; } - rc.Record("do search"); - - //step 3: cluster result - SearchContext::ResultSet result_set; - ClusterResult(output_ids, output_distence, context->nq(), inner_k, result_set); - rc.Record("cluster result"); - - //step 4: pick up topk result - TopkResult(result_set, inner_k, context->GetResult()); - rc.Record("reduce topk"); - - //step 5: calculate score between 0 ~ 100 - CalcScore(context->nq(), context->vectors(), index_engine_->Dimension(), context->GetResult(), result_set); - context->GetResult().swap(result_set); - rc.Record("calculate score"); - //step 6: notify to send result to client context->IndexSearchDone(index_id_); } From ff006926666fc08db138f6e4685ac6ee1080eab9 Mon Sep 17 00:00:00 2001 From: groot Date: Thu, 13 Jun 2019 10:08:45 +0800 Subject: [PATCH 2/2] chnagelog Former-commit-id: 976eb7fe04f1e66e2501451491cc7dff052fbda7 --- cpp/CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/cpp/CHANGELOG.md b/cpp/CHANGELOG.md index 87fd3ee2f3..4822bcb16b 100644 --- a/cpp/CHANGELOG.md +++ b/cpp/CHANGELOG.md @@ -34,6 +34,7 @@ Please mark all change in change log and use the ticket from JIRA. - MS-32 - Fix thrift error - MS-34 - Fix prometheus-cpp thirdparty - MS-67 - Fix license check bug +- MS-76 - Fix pipeline crash bug ## Improvement