From aca1aeb5ec90f768ace49df8f934ed56f800d740 Mon Sep 17 00:00:00 2001 From: chen qingxiang <67679556+godchen0212@users.noreply.github.com> Date: Fri, 7 Aug 2020 09:37:41 +0800 Subject: [PATCH] fix bug casued by merge and drop at the same time (#3160) * add log message Signed-off-by: godchen0212 * format code Signed-off-by: godchen0212 * fix bug casued by merge and drop at the same time Signed-off-by: godchen0212 --- core/src/db/DBImpl.cpp | 5 +++++ core/src/db/snapshot/CompoundOperations.cpp | 5 +++++ core/src/db/snapshot/Store.h | 3 ++- core/src/server/delivery/request/CreateCollectionReq.cpp | 9 +++++++++ 4 files changed, 21 insertions(+), 1 deletion(-) diff --git a/core/src/db/DBImpl.cpp b/core/src/db/DBImpl.cpp index 7e3269b7cf..149dbe5722 100644 --- a/core/src/db/DBImpl.cpp +++ b/core/src/db/DBImpl.cpp @@ -167,6 +167,7 @@ DBImpl::CreateCollection(const snapshot::CreateCollectionContext& context) { auto ctx = context; + LOG_SERVER_DEBUG_ << "check id auto gen"; // default id is auto-generated auto params = ctx.collection->GetParams(); if (params.find(PARAM_UID_AUTOGEN) == params.end()) { @@ -174,6 +175,7 @@ DBImpl::CreateCollection(const snapshot::CreateCollectionContext& context) { ctx.collection->SetParams(params); } + LOG_SERVER_DEBUG_ << "check uid existence"; // check uid existence snapshot::FieldPtr uid_field; for (auto& pair : ctx.fields_schema) { @@ -183,6 +185,7 @@ DBImpl::CreateCollection(const snapshot::CreateCollectionContext& context) { } } + LOG_SERVER_DEBUG_ << "add uid field"; // add uid field if not specified if (uid_field == nullptr) { uid_field = std::make_shared(DEFAULT_UID_NAME, 0, DataType::INT64); @@ -195,7 +198,9 @@ DBImpl::CreateCollection(const snapshot::CreateCollectionContext& context) { 0, 0, DEFAULT_DELETED_DOCS_NAME, milvus::engine::FieldElementType::FET_DELETED_DOCS); ctx.fields_schema[uid_field] = {bloom_filter_element, delete_doc_element}; + LOG_SERVER_DEBUG_ << "Create Collection Operation"; auto op = std::make_shared(ctx); + LOG_SERVER_DEBUG_ << "Create Collection Operation end"; return op->Push(); } diff --git a/core/src/db/snapshot/CompoundOperations.cpp b/core/src/db/snapshot/CompoundOperations.cpp index 1edc366600..69d2d4efcc 100644 --- a/core/src/db/snapshot/CompoundOperations.cpp +++ b/core/src/db/snapshot/CompoundOperations.cpp @@ -736,6 +736,11 @@ GetSnapshotIDsOperation::GetSnapshotIDsOperation(ID_TYPE collection_id, bool rev Status GetSnapshotIDsOperation::DoExecute(StorePtr store) { + CollectionPtr collection; + STATUS_CHECK(store->GetResource(collection_id_, collection)); + if (!collection || !collection->IsActive()) { + return Status::OK(); + } ids_ = store->AllActiveCollectionCommitIds(collection_id_, reversed_); return Status::OK(); } diff --git a/core/src/db/snapshot/Store.h b/core/src/db/snapshot/Store.h index dca1936909..02d4328981 100644 --- a/core/src/db/snapshot/Store.h +++ b/core/src/db/snapshot/Store.h @@ -194,7 +194,8 @@ class Store : public std::enable_shared_from_this { AllActiveCollectionIds(bool reversed = true) const { IDS_TYPE ids; IDS_TYPE selected_ids; - adapter_->SelectResourceIDs(selected_ids, "", {""}); + std::vector filter_states = {State::ACTIVE}; + adapter_->SelectResourceIDs(selected_ids, "", filter_states); if (!reversed) { ids = selected_ids; diff --git a/core/src/server/delivery/request/CreateCollectionReq.cpp b/core/src/server/delivery/request/CreateCollectionReq.cpp index 363522f521..4181b9d363 100644 --- a/core/src/server/delivery/request/CreateCollectionReq.cpp +++ b/core/src/server/delivery/request/CreateCollectionReq.cpp @@ -60,7 +60,13 @@ CreateCollectionReq::OnExecute() { // step 2: create snapshot collection context engine::snapshot::CreateCollectionContext create_collection_context; + LOG_SERVER_DEBUG_ << "make collection_schema"; auto collection_schema = std::make_shared(collection_name_, extra_params_); + if (collection_schema == nullptr) { + LOG_SERVER_DEBUG_ << "collection_schema null"; + } + + LOG_SERVER_DEBUG_ << "create_collection_context"; create_collection_context.collection = collection_schema; for (auto& field_kv : fields_) { auto& field_name = field_kv.first; @@ -77,6 +83,7 @@ CreateCollectionReq::OnExecute() { index_name = index_params["name"]; } + LOG_SERVER_DEBUG_ << "checkout Default_UID_NAME"; // validate id field if (field_name == engine::DEFAULT_UID_NAME) { if (field_type != engine::DataType::INT64) { @@ -103,9 +110,11 @@ CreateCollectionReq::OnExecute() { } // step 3: create collection + LOG_SERVER_FATAL_ << "create collection"; status = DBWrapper::DB()->CreateCollection(create_collection_context); fiu_do_on("CreateCollectionReq.OnExecute.invalid_db_execute", status = Status(milvus::SERVER_UNEXPECTED_ERROR, "")); + LOG_SERVER_FATAL_ << "create collection end"; if (!status.ok()) { // collection could exist if (status.code() == DB_ALREADY_EXIST) {