Unverified Commit 34b4d725 authored by Jin Hai's avatar Jin Hai Committed by GitHub
Browse files

Add exception throw on mysql meta error (#2490)



* Add exception throw on mysql meta error

Signed-off-by: default avatarJinHai-CN <hai.jin@zilliz.com>

* Fix lint

Signed-off-by: default avatarJinHai-CN <hai.jin@zilliz.com>

* [skip ci] update changelog

Signed-off-by: default avatarJinHai-CN <hai.jin@zilliz.com>

* Update

Signed-off-by: default avatarJinHai-CN <hai.jin@zilliz.com>

* Update

Signed-off-by: default avatarjinhai <hai.jin@zilliz.com>

* Fix Unit test

Signed-off-by: default avatarJinHai-CN <hai.jin@zilliz.com>
parent a6a90219
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@ Please mark all change in change log and use the issue from GitHub
-   \#2429 Fix Milvus 0.9.1 performance degrade issue
-   \#2441 Improve Knowhere code coverage
-   \#2466 optimize k-selection implemention of faiss gpu version
-   \#2489 Add exception throw on mysql meta error
-   \#2495 Add creating lock file failure reason.

## Task
+2 −6
Original line number Diff line number Diff line
@@ -13,9 +13,7 @@
#include <fiu-local.h>
#include <thread>

namespace milvus {
namespace engine {
namespace meta {
namespace milvus::engine::meta {

// Do a simple form of in-use connection limiting: wait to return
// a connection until there are a reasonably low number in use
@@ -84,6 +82,4 @@ MySQLConnectionPool::max_idle_time() {
    return max_idle_time_;
}

}  // namespace meta
}  // namespace engine
}  // namespace milvus
}  // namespace milvus::engine::meta
+5 −3
Original line number Diff line number Diff line
@@ -52,7 +52,7 @@ template <typename T>
void
DistributeBatch(const T& id_array, std::vector<std::vector<std::string>>& id_groups) {
    std::vector<std::string> temp_group;
    constexpr uint64_t SQL_BATCH_SIZE = 50;
    //    constexpr uint64_t SQL_BATCH_SIZE = 50; // duplicate variable
    for (auto& id : id_array) {
        temp_group.push_back(id);
        if (temp_group.size() >= SQL_BATCH_SIZE) {
@@ -246,12 +246,14 @@ MySQLMetaImpl::NextFileId(std::string& file_id) {

void
MySQLMetaImpl::ValidateMetaSchema() {
    if (nullptr == mysql_connection_pool_) {
    if (mysql_connection_pool_ == nullptr) {
        throw Exception(DB_ERROR, "MySQL connection pool is invalid");
        return;
    }

    mysqlpp::ScopedConnection connectionPtr(*mysql_connection_pool_, safe_grab_);
    if (connectionPtr == nullptr) {
        throw Exception(DB_ERROR, "Can't construct MySQL connection");
        return;
    }

@@ -336,7 +338,7 @@ MySQLMetaImpl::Initialize() {

    // step 3: connect mysql
    unsigned int thread_hint = std::thread::hardware_concurrency();
    int max_pool_size = (thread_hint > 8) ? thread_hint : 8;
    int max_pool_size = (thread_hint > 8) ? static_cast<int>(thread_hint) : 8;
    int port = 0;
    if (!uri_info.port_.empty()) {
        port = std::stoi(uri_info.port_);
+1 −1
Original line number Diff line number Diff line
@@ -182,7 +182,7 @@ class MySQLMetaImpl : public Meta {
    const int mode_;

    std::shared_ptr<MySQLConnectionPool> mysql_connection_pool_;
    bool safe_grab_ = false;
    bool safe_grab_ = false;  // Safely graps a connection from mysql pool

    std::mutex meta_mutex_;
    std::mutex genid_mutex_;
+1 −1
Original line number Diff line number Diff line
@@ -153,7 +153,7 @@ SqliteMetaImpl::ValidateMetaSchema() {
    bool is_null_connector{ConnectorPtr == nullptr};
    fiu_do_on("SqliteMetaImpl.ValidateMetaSchema.NullConnection", is_null_connector = true);
    if (is_null_connector) {
        return;
        throw Exception(DB_ERROR, "Connector is null pointer");
    }

    // old meta could be recreated since schema changed, throw exception if meta schema is not compatible
Loading