diff --git a/be/src/common/config.cpp b/be/src/common/config.cpp index a433b7ee8a..f7f4cc99a4 100644 --- a/be/src/common/config.cpp +++ b/be/src/common/config.cpp @@ -1602,20 +1602,23 @@ void update_config(const std::string& field, const std::string& value) { } } -Status set_fuzzy_config(const std::string& field, const std::string& value) { - LOG(INFO) << fmt::format("FUZZY MODE: {} has been set to {}", field, value); - return set_config(field, value, false, true); -} +Status set_fuzzy_configs() { + std::unordered_map fuzzy_field_and_value; -void set_fuzzy_configs() { - // random value true or false - static_cast( - set_fuzzy_config("disable_storage_page_cache", ((rand() % 2) == 0) ? "true" : "false")); - static_cast( - set_fuzzy_config("enable_system_metrics", ((rand() % 2) == 0) ? "true" : "false")); - // random value from 8 to 48 - // s = set_fuzzy_config("doris_scanner_thread_pool_thread_num", std::to_string((rand() % 41) + 8)); - // LOG(INFO) << s.to_string(); + // if have set enable_fuzzy_mode=true in be.conf, will fuzzy those field and values + fuzzy_field_and_value["disable_storage_page_cache"] = ((rand() % 2) == 0) ? "true" : "false"; + fuzzy_field_and_value["enable_system_metrics"] = ((rand() % 2) == 0) ? "true" : "false"; + + fmt::memory_buffer buf; + for (auto it = fuzzy_field_and_value.begin(); it != fuzzy_field_and_value.end(); it++) { + const auto& field = it->first; + const auto& value = it->second; + RETURN_IF_ERROR(set_config(field, value, false, true)); + fmt::format_to(buf, "{}={}, ", field, value); + } + LOG(INFO) << fmt::format("FUZZY MODE IN BE: those variables have been changed: ({}).", + fmt::to_string(buf)); + return Status::OK(); } std::mutex* get_mutable_string_config_lock() { diff --git a/be/src/common/config.h b/be/src/common/config.h index 5c298f906c..6fcbecd8f7 100644 --- a/be/src/common/config.h +++ b/be/src/common/config.h @@ -1364,9 +1364,7 @@ std::mutex* get_mutable_string_config_lock(); std::vector> get_config_info(); -Status set_fuzzy_config(const std::string& field, const std::string& value); - -void set_fuzzy_configs(); +Status set_fuzzy_configs(); void update_config(const std::string& field, const std::string& value); diff --git a/be/src/service/doris_main.cpp b/be/src/service/doris_main.cpp index b3962af87e..a3ea8f14e0 100644 --- a/be/src/service/doris_main.cpp +++ b/be/src/service/doris_main.cpp @@ -380,8 +380,11 @@ int main(int argc, char** argv) { doris::init_thrift_logging(); if (doris::config::enable_fuzzy_mode) { - LOG(INFO) << "enable_fuzzy_mode is true, set fuzzy configs"; - doris::config::set_fuzzy_configs(); + Status status = doris::config::set_fuzzy_configs(); + if (!status.ok()) { + LOG(WARNING) << "Failed to initialize fuzzy config: " << status; + exit(1); + } } #if !defined(__SANITIZE_ADDRESS__) && !defined(ADDRESS_SANITIZER) && !defined(LEAK_SANITIZER) && \