From 9cd12878aee29bcd2bffeab96356b7b497c3f40c Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Thu, 21 Nov 2024 14:10:16 +0800 Subject: [PATCH] branch-3.0: [Fix](ms) Fix ci-uncaught ut coredump due to dynamic rate limit setting #44362 (#44370) Cherry-picked from #44362 Co-authored-by: Siyang Tang --- cloud/script/run_all_tests.sh | 2 ++ cloud/src/meta-service/meta_service_http.cpp | 14 +++++++------- run-cloud-ut.sh | 1 + 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/cloud/script/run_all_tests.sh b/cloud/script/run_all_tests.sh index eaddd4ff78fad3..330fb00449350b 100644 --- a/cloud/script/run_all_tests.sh +++ b/cloud/script/run_all_tests.sh @@ -143,11 +143,13 @@ for i in *_test; do patchelf --set-rpath "$(pwd)" "${i}" fi + set -euo pipefail if [[ "${filter}" == "" ]]; then LLVM_PROFILE_FILE="./report/${i}.profraw" "./${i}" --gtest_print_time=true --gtest_output="xml:${i}.xml" else LLVM_PROFILE_FILE="./report/${i}.profraw" "./${i}" --gtest_print_time=true --gtest_output="xml:${i}.xml" --gtest_filter="${filter}" fi + set +euo pipefail unittest_files[${#unittest_files[*]}]="${i}" echo "--------------------------" fi diff --git a/cloud/src/meta-service/meta_service_http.cpp b/cloud/src/meta-service/meta_service_http.cpp index bb193092be93a4..be00b8d93475d3 100644 --- a/cloud/src/meta-service/meta_service_http.cpp +++ b/cloud/src/meta-service/meta_service_http.cpp @@ -409,8 +409,8 @@ static HttpResponse process_adjust_rate_limit(MetaServiceImpl* service, brpc::Co processors[0b101] = std::move(set_instance_qps_limit); processors[0b111] = std::move(set_instance_rpc_qps_limit); - uint8_t level = (0x01 & qps_limit_str.empty()) | ((0x01 & rpc_name.empty()) << 1) | - ((0x01 & instance_id.empty()) << 2); + uint8_t level = (0x01 & !qps_limit_str.empty()) | ((0x01 & !rpc_name.empty()) << 1) | + ((0x01 & !instance_id.empty()) << 2); DCHECK_LT(level, 8); @@ -420,10 +420,13 @@ static HttpResponse process_adjust_rate_limit(MetaServiceImpl* service, brpc::Co static HttpResponse process_query_rate_limit(MetaServiceImpl* service, brpc::Controller* cntl) { auto rate_limiter = service->rate_limiter(); rapidjson::Document d; + d.SetObject(); auto get_qps_limit = [&d](std::string_view rpc_name, std::shared_ptr rpc_limiter) { rapidjson::Document node; + node.SetObject(); rapidjson::Document sub; + sub.SetObject(); auto get_qps_token_limit = [&](std::string_view instance_id, std::shared_ptr qps_token) { sub.AddMember(rapidjson::StringRef(instance_id.data(), instance_id.size()), @@ -431,10 +434,7 @@ static HttpResponse process_query_rate_limit(MetaServiceImpl* service, brpc::Con }; rpc_limiter->for_each_qps_token(std::move(get_qps_token_limit)); - auto max_qps_limit = std::to_string(rpc_limiter->max_qps_limit()); - node.AddMember("RPC qps limit", - rapidjson::StringRef(max_qps_limit.data(), max_qps_limit.size()), - d.GetAllocator()); + node.AddMember("RPC qps limit", rpc_limiter->max_qps_limit(), d.GetAllocator()); node.AddMember("instance specific qps limit", sub, d.GetAllocator()); d.AddMember(rapidjson::StringRef(rpc_name.data(), rpc_name.size()), node, d.GetAllocator()); }; @@ -443,7 +443,7 @@ static HttpResponse process_query_rate_limit(MetaServiceImpl* service, brpc::Con rapidjson::StringBuffer sb; rapidjson::PrettyWriter writer(sb); d.Accept(writer); - return http_json_reply(MetaServiceCode::OK, sb.GetString()); + return http_json_reply(MetaServiceCode::OK, "", sb.GetString()); } static HttpResponse process_decode_key(MetaServiceImpl*, brpc::Controller* ctrl) { diff --git a/run-cloud-ut.sh b/run-cloud-ut.sh index 16473b1a2a8873..c74eee7b5f3eb4 100755 --- a/run-cloud-ut.sh +++ b/run-cloud-ut.sh @@ -228,6 +228,7 @@ cd test # FILTER: binary_name:gtest_filter # FILTER: meta_service_test:DetachSchemaKVTest.* # ./run_all_tests.sh --test "\"$(echo "${FILTER}" | awk -F: '{print $1}')\"" --filter "\"$(echo "${FILTER}" | awk -F: '{print $2}')\"" --fdb "\"${FDB}\"" +set -euo pipefail if [[ "_${ENABLE_CLANG_COVERAGE}" == "_ON" ]]; then bash -x ./run_all_tests.sh --coverage --test "$(echo "${FILTER}" | awk -F: '{print $1}')" --filter "$(echo "${FILTER}" | awk -F: '{print $2}')" --fdb "${FDB}" else