mirror of https://github.com/milvus-io/milvus.git
Add exception throw on mysql meta error (#2490)
* Add exception throw on mysql meta error Signed-off-by: JinHai-CN <hai.jin@zilliz.com> * Fix lint Signed-off-by: JinHai-CN <hai.jin@zilliz.com> * [skip ci] update changelog Signed-off-by: JinHai-CN <hai.jin@zilliz.com> * Update Signed-off-by: JinHai-CN <hai.jin@zilliz.com> * Update Signed-off-by: jinhai <hai.jin@zilliz.com> * Fix Unit test Signed-off-by: JinHai-CN <hai.jin@zilliz.com>pull/2515/head
parent
a6a9021974
commit
34b4d72517
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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_);
|
||||
|
|
|
@ -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_;
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -56,7 +56,7 @@ TEST_F(MetaTest, COLLECTION_TEST) {
|
|||
ASSERT_TRUE(status.ok());
|
||||
}
|
||||
|
||||
TEST_F(MetaTest, FALID_TEST) {
|
||||
TEST_F(MetaTest, FAILED_TEST) {
|
||||
fiu_init(0);
|
||||
auto options = GetOptions();
|
||||
auto collection_id = "meta_test_table";
|
||||
|
@ -66,7 +66,7 @@ TEST_F(MetaTest, FALID_TEST) {
|
|||
|
||||
{
|
||||
FIU_ENABLE_FIU("SqliteMetaImpl.ValidateMetaSchema.NullConnection");
|
||||
milvus::engine::meta::SqliteMetaImpl impl(options.meta_);
|
||||
ASSERT_ANY_THROW(milvus::engine::meta::SqliteMetaImpl impl(options.meta_));
|
||||
fiu_disable("SqliteMetaImpl.ValidateMetaSchema.NullConnection");
|
||||
}
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue