From 24daade18e4d99b85e58eb4cb56de100a4cc7e7f Mon Sep 17 00:00:00 2001 From: Yhz Date: Sun, 8 Mar 2020 14:30:02 +0800 Subject: [PATCH 1/6] fix config wal valid_recovery_error_ignore bug Signed-off-by: Yhz --- CHANGELOG.md | 1 + core/src/server/Config.cpp | 2 +- core/src/server/Config.h | 3 +++ 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index abb94a552c..1fa431015c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -42,6 +42,7 @@ Please mark all change in change log and use the issue from GitHub - \#1529 Fix server crash when cache_insert_data enabled - \#1530 Set table file with correct engine type in meta - \#1535 Degradation searching performance with metric_type: binary_idmap +- \#1549 Fix server/wal config setting bug ## Feature - \#216 Add CLI to get server info diff --git a/core/src/server/Config.cpp b/core/src/server/Config.cpp index f0b88fa98c..8506a28f0f 100644 --- a/core/src/server/Config.cpp +++ b/core/src/server/Config.cpp @@ -2013,7 +2013,7 @@ Config::SetWalConfigEnable(const std::string& value) { Status Config::SetWalConfigRecoveryErrorIgnore(const std::string& value) { CONFIG_CHECK(CheckWalConfigRecoveryErrorIgnore(value)); - return SetConfigValueInMem(CONFIG_WAL, CONFIG_WAL_RECOVERY_ERROR_IGNORE_DEFAULT, value); + return SetConfigValueInMem(CONFIG_WAL, CONFIG_WAL_RECOVERY_ERROR_IGNORE, value); } Status diff --git a/core/src/server/Config.h b/core/src/server/Config.h index 1bd99a6b9d..77bdd5def6 100644 --- a/core/src/server/Config.h +++ b/core/src/server/Config.h @@ -191,6 +191,9 @@ class Config { Status SetConfigCli(const std::string& parent_key, const std::string& child_key, const std::string& value); + Status + CheckDuplicatePort(); + Status UpdateFileConfigFromMem(const std::string& parent_key, const std::string& child_key); From 5892d4b9ba3e1255204188f92760e3ad289e1854 Mon Sep 17 00:00:00 2001 From: Yhz Date: Sun, 8 Mar 2020 16:22:13 +0800 Subject: [PATCH 2/6] remove port check declaration Signed-off-by: Yhz --- core/src/server/Config.h | 3 --- 1 file changed, 3 deletions(-) diff --git a/core/src/server/Config.h b/core/src/server/Config.h index 77bdd5def6..1bd99a6b9d 100644 --- a/core/src/server/Config.h +++ b/core/src/server/Config.h @@ -191,9 +191,6 @@ class Config { Status SetConfigCli(const std::string& parent_key, const std::string& child_key, const std::string& value); - Status - CheckDuplicatePort(); - Status UpdateFileConfigFromMem(const std::string& parent_key, const std::string& child_key); From 8cd5d64f06bec7bf84f3adfbe0d0e0f0204c8e86 Mon Sep 17 00:00:00 2001 From: Yhz Date: Sun, 8 Mar 2020 18:06:25 +0800 Subject: [PATCH 3/6] use bool conversation Signed-off-by: Yhz --- core/src/server/Config.cpp | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/core/src/server/Config.cpp b/core/src/server/Config.cpp index 8506a28f0f..f1a3a421f7 100644 --- a/core/src/server/Config.cpp +++ b/core/src/server/Config.cpp @@ -1529,8 +1529,7 @@ Status Config::GetStorageConfigS3Enable(bool& value) { std::string str = GetConfigStr(CONFIG_STORAGE, CONFIG_STORAGE_S3_ENABLE, CONFIG_STORAGE_S3_ENABLE_DEFAULT); CONFIG_CHECK(CheckStorageConfigS3Enable(str)); - std::transform(str.begin(), str.end(), str.begin(), ::tolower); - value = (str == "true" || str == "on" || str == "yes" || str == "1"); + CONFIG_CHECK(StringHelpFunctions::ConvertToBoolean(str, value)); return Status::OK(); } @@ -1569,8 +1568,7 @@ Status Config::GetMetricConfigEnableMonitor(bool& value) { std::string str = GetConfigStr(CONFIG_METRIC, CONFIG_METRIC_ENABLE_MONITOR, CONFIG_METRIC_ENABLE_MONITOR_DEFAULT); CONFIG_CHECK(CheckMetricConfigEnableMonitor(str)); - std::transform(str.begin(), str.end(), str.begin(), ::tolower); - value = (str == "true" || str == "on" || str == "yes" || str == "1"); + CONFIG_CHECK(StringHelpFunctions::ConvertToBoolean(str, value)); return Status::OK(); } @@ -1671,8 +1669,7 @@ Status Config::GetGpuResourceConfigEnable(bool& value) { std::string str = GetConfigStr(CONFIG_GPU_RESOURCE, CONFIG_GPU_RESOURCE_ENABLE, CONFIG_GPU_RESOURCE_ENABLE_DEFAULT); CONFIG_CHECK(CheckGpuResourceConfigEnable(str)); - std::transform(str.begin(), str.end(), str.begin(), ::tolower); - value = (str == "true" || str == "on" || str == "yes" || str == "1"); + CONFIG_CHECK(StringHelpFunctions::ConvertToBoolean(str, value)); return Status::OK(); } @@ -1774,8 +1771,7 @@ Status Config::GetWalConfigEnable(bool& wal_enable) { std::string str = GetConfigStr(CONFIG_WAL, CONFIG_WAL_ENABLE, CONFIG_WAL_ENABLE_DEFAULT); CONFIG_CHECK(CheckWalConfigEnable(str)); - std::transform(str.begin(), str.end(), str.begin(), ::tolower); - wal_enable = (str == "true" || str == "on" || str == "yes" || str == "1"); + CONFIG_CHECK(StringHelpFunctions::ConvertToBoolean(str, wal_enable)); return Status::OK(); } @@ -1784,8 +1780,7 @@ Config::GetWalConfigRecoveryErrorIgnore(bool& recovery_error_ignore) { std::string str = GetConfigStr(CONFIG_WAL, CONFIG_WAL_RECOVERY_ERROR_IGNORE, CONFIG_WAL_RECOVERY_ERROR_IGNORE_DEFAULT); CONFIG_CHECK(CheckWalConfigRecoveryErrorIgnore(str)); - std::transform(str.begin(), str.end(), str.begin(), ::tolower); - recovery_error_ignore = (str == "true" || str == "on" || str == "yes" || str == "1"); + CONFIG_CHECK(StringHelpFunctions::ConvertToBoolean(str, recovery_error_ignore)); return Status::OK(); } From c88fad09892694c2c6987a603e460f7b56eb1d58 Mon Sep 17 00:00:00 2001 From: Yhz Date: Sun, 8 Mar 2020 21:41:38 +0800 Subject: [PATCH 4/6] handler json error when create index Signed-off-by: Yhz --- core/src/server/web_impl/handler/WebRequestHandler.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/core/src/server/web_impl/handler/WebRequestHandler.cpp b/core/src/server/web_impl/handler/WebRequestHandler.cpp index 92d68e77ca..72f04aa748 100644 --- a/core/src/server/web_impl/handler/WebRequestHandler.cpp +++ b/core/src/server/web_impl/handler/WebRequestHandler.cpp @@ -1046,7 +1046,9 @@ WebRequestHandler::CreateIndex(const OString& table_name, const OString& body) { auto status = request_handler_.CreateIndex(context_ptr_, table_name->std_str(), index, request_json["params"]); ASSIGN_RETURN_STATUS_DTO(status); } catch (nlohmann::detail::parse_error& e) { + RETURN_STATUS_DTO(BODY_PARSE_FAIL, e.what()) } catch (nlohmann::detail::type_error& e) { + RETURN_STATUS_DTO(BODY_PARSE_FAIL, e.what()) } ASSIGN_RETURN_STATUS_DTO(Status::OK()) From b3b3111a7a3985443424040af7ac86ee8a018f32 Mon Sep 17 00:00:00 2001 From: Yhz Date: Sun, 8 Mar 2020 22:26:28 +0800 Subject: [PATCH 5/6] change create index url Signed-off-by: Yhz --- core/src/server/web_impl/controller/WebController.hpp | 2 +- core/unittest/server/test_web.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/core/src/server/web_impl/controller/WebController.hpp b/core/src/server/web_impl/controller/WebController.hpp index ab2a26c2ca..ea9574b026 100644 --- a/core/src/server/web_impl/controller/WebController.hpp +++ b/core/src/server/web_impl/controller/WebController.hpp @@ -336,7 +336,7 @@ class WebController : public oatpp::web::server::api::ApiController { ADD_CORS(CreateIndex) - ENDPOINT("POST", "/tables/{collection_name}/indexes", CreateIndex, + ENDPOINT("POST", "/collections/{collection_name}/indexes", CreateIndex, PATH(String, collection_name), BODY_STRING(String, body)) { TimeRecorder tr(std::string(WEB_LOG_PREFIX) + "POST \'/tables/" + collection_name->std_str() + "/indexes\'"); tr.RecordSection("Received request."); diff --git a/core/unittest/server/test_web.cpp b/core/unittest/server/test_web.cpp index 073e08ec91..00703482e1 100644 --- a/core/unittest/server/test_web.cpp +++ b/core/unittest/server/test_web.cpp @@ -646,7 +646,7 @@ class TestClient : public oatpp::web::client::ApiClient { API_CALL("OPTIONS", "/collections/{collection_name}/indexes", optionsIndexes, PATH(String, collection_name, "collection_name")) - API_CALL("POST", "/tables/{table_name}/indexes", createIndex, PATH(String, table_name, "table_name"), + API_CALL("POST", "/collections/{collection_name}/indexes", createIndex, PATH(String, collection_name, "collection_name"), BODY_STRING(OString, body)) API_CALL("GET", "/collections/{collection_name}/indexes", getIndex, PATH(String, collection_name, "collection_name")) From c5bfcaef74827ed9145b8403d9479af77beeb962 Mon Sep 17 00:00:00 2001 From: Yhz Date: Mon, 9 Mar 2020 09:22:39 +0800 Subject: [PATCH 6/6] lower variable in systemop Signed-off-by: Yhz --- core/src/server/web_impl/controller/WebController.hpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/core/src/server/web_impl/controller/WebController.hpp b/core/src/server/web_impl/controller/WebController.hpp index ea9574b026..55a51168a3 100644 --- a/core/src/server/web_impl/controller/WebController.hpp +++ b/core/src/server/web_impl/controller/WebController.hpp @@ -674,15 +674,15 @@ class WebController : public oatpp::web::server::api::ApiController { ADD_CORS(SystemOp) - ENDPOINT("PUT", "/system/{Op}", SystemOp, PATH(String, Op), BODY_STRING(String, body_str)) { - TimeRecorder tr(std::string(WEB_LOG_PREFIX) + "PUT \'/system/" + Op->std_str() + "\'"); + ENDPOINT("PUT", "/system/{op}", SystemOp, PATH(String, op), BODY_STRING(String, body_str)) { + TimeRecorder tr(std::string(WEB_LOG_PREFIX) + "PUT \'/system/" + op->std_str() + "\'"); tr.RecordSection("Received request."); WebRequestHandler handler = WebRequestHandler(); handler.RegisterRequestHandler(::milvus::server::RequestHandler()); String response_str; - auto status_dto = handler.SystemOp(Op, body_str, response_str); + auto status_dto = handler.SystemOp(op, body_str, response_str); std::shared_ptr response; switch (status_dto->code->getValue()) {