未验证 提交 aca1aeb5 编写于 作者: C chen qingxiang 提交者: GitHub

fix bug casued by merge and drop at the same time (#3160)

* add log message
Signed-off-by: Ngodchen0212 <qingxiang.chen@zilliz.com>

* format code
Signed-off-by: Ngodchen0212 <qingxiang.chen@zilliz.com>

* fix bug casued by merge and drop at the same time
Signed-off-by: Ngodchen0212 <qingxiang.chen@zilliz.com>
上级 596808a3
......@@ -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<snapshot::Field>(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<snapshot::CreateCollectionOperation>(ctx);
LOG_SERVER_DEBUG_ << "Create Collection Operation end";
return op->Push();
}
......
......@@ -736,6 +736,11 @@ GetSnapshotIDsOperation::GetSnapshotIDsOperation(ID_TYPE collection_id, bool rev
Status
GetSnapshotIDsOperation::DoExecute(StorePtr store) {
CollectionPtr collection;
STATUS_CHECK(store->GetResource<Collection>(collection_id_, collection));
if (!collection || !collection->IsActive()) {
return Status::OK();
}
ids_ = store->AllActiveCollectionCommitIds(collection_id_, reversed_);
return Status::OK();
}
......
......@@ -194,7 +194,8 @@ class Store : public std::enable_shared_from_this<Store> {
AllActiveCollectionIds(bool reversed = true) const {
IDS_TYPE ids;
IDS_TYPE selected_ids;
adapter_->SelectResourceIDs<Collection, std::string>(selected_ids, "", {""});
std::vector<State> filter_states = {State::ACTIVE};
adapter_->SelectResourceIDs<Collection>(selected_ids, "", filter_states);
if (!reversed) {
ids = selected_ids;
......
......@@ -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<engine::snapshot::Collection>(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) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册