diff --git a/core/src/db/insert/MemCollection.cpp b/core/src/db/insert/MemCollection.cpp index cd4cae1ce9..fc54ea3b67 100644 --- a/core/src/db/insert/MemCollection.cpp +++ b/core/src/db/insert/MemCollection.cpp @@ -54,6 +54,7 @@ MemCollection::Add(int64_t partition_id, const milvus::engine::VectorSourcePtr& Status status; if (current_mem_segment == nullptr || current_mem_segment->IsFull()) { MemSegmentPtr new_mem_segment = std::make_shared(collection_id_, partition_id, options_); + STATUS_CHECK(new_mem_segment->CreateSegment()); status = new_mem_segment->Add(source); if (status.ok()) { mem_segments_[partition_id].emplace_back(new_mem_segment); diff --git a/core/src/db/insert/MemSegment.cpp b/core/src/db/insert/MemSegment.cpp index fee5ff3884..6a161fc5cd 100644 --- a/core/src/db/insert/MemSegment.cpp +++ b/core/src/db/insert/MemSegment.cpp @@ -33,7 +33,7 @@ namespace engine { MemSegment::MemSegment(int64_t collection_id, int64_t partition_id, const DBOptions& options) : collection_id_(collection_id), partition_id_(partition_id), options_(options) { current_mem_ = 0; - CreateSegment(); + // CreateSegment(); } Status diff --git a/core/src/db/insert/MemSegment.h b/core/src/db/insert/MemSegment.h index 46f0485400..ea5c074d56 100644 --- a/core/src/db/insert/MemSegment.h +++ b/core/src/db/insert/MemSegment.h @@ -32,6 +32,9 @@ class MemSegment { ~MemSegment() = default; public: + Status + CreateSegment(); + Status Add(const VectorSourcePtr& source); @@ -54,9 +57,6 @@ class MemSegment { GetSegmentId() const; private: - Status - CreateSegment(); - Status GetSingleEntitySize(int64_t& single_size); diff --git a/core/src/db/meta/backend/SqliteEngine.cpp b/core/src/db/meta/backend/SqliteEngine.cpp index 57c78d253a..2dba486f51 100644 --- a/core/src/db/meta/backend/SqliteEngine.cpp +++ b/core/src/db/meta/backend/SqliteEngine.cpp @@ -225,8 +225,12 @@ SqliteEngine::ExecuteTransaction(const std::vector& sql_contex } std::lock_guard lock(meta_mutex_); - int rc = SQLITE_OK; - sqlite3_exec(db_, "BEGIN", NULL, NULL, NULL); + int rc = sqlite3_exec(db_, "BEGIN", NULL, NULL, NULL); + if (rc != SQLITE_OK) { + std::string sql_err = + std::string("(code:") + std::to_string(sqlite3_errcode(db_)) + ", msg:" + sqlite3_errmsg(db_) + ")"; + return Status(DB_ERROR, sql_err); + } for (size_t i = 0; i < sql_contexts.size(); i++) { rc = sqlite3_exec(db_, sqls[i].c_str(), NULL, NULL, NULL); @@ -252,7 +256,6 @@ SqliteEngine::ExecuteTransaction(const std::vector& sql_contex if (SQLITE_OK != rc) { std::string err = "Execute Fail:"; err += sqlite3_errmsg(db_); - std::cerr << err << std::endl; sqlite3_exec(db_, "ROLLBACK", NULL, NULL, NULL); return Status(SERVER_UNEXPECTED_ERROR, err); }