From ae98a92fc9678e3977db0011990a9256f6f8fc9d Mon Sep 17 00:00:00 2001 From: groot Date: Thu, 28 May 2020 22:35:02 +0800 Subject: [PATCH] merge before index Signed-off-by: groot --- core/src/db/DBImpl.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/core/src/db/DBImpl.cpp b/core/src/db/DBImpl.cpp index f9d12452..b7e6a088 100644 --- a/core/src/db/DBImpl.cpp +++ b/core/src/db/DBImpl.cpp @@ -1408,7 +1408,14 @@ DBImpl::CreateIndex(const std::shared_ptr& context, const std:: // step 1: wait merge file thread finished to avoid duplicate data bug auto status = Flush(); WaitMergeFileFinish(); // let merge file thread finish - std::set merge_collection_ids; + + // merge all files for this collection, including its partitions + std::set merge_collection_ids = {collection_id}; + std::vector partition_array; + status = meta_ptr_->ShowPartitions(collection_id, partition_array); + for (auto& schema : partition_array) { + merge_collection_ids.insert(schema.collection_id_); + } StartMergeTask(merge_collection_ids, true); // start force-merge task WaitMergeFileFinish(); // let force-merge file thread finish -- GitLab