This is an automated email from the ASF dual-hosted git repository.
zhangstar333 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/master by this push:
new 55d75e7f757 [improve](conf)refactor fuzzy mode in BE (#31412)
55d75e7f757 is described below
commit 55d75e7f7573482ab1298de43f38fa87556f72a6
Author: zhangstar333 <[email protected]>
AuthorDate: Thu Feb 29 17:22:52 2024 +0800
[improve](conf)refactor fuzzy mode in BE (#31412)
refactor the code of fuzzy in BE, and will be add more variables in it,
then could test case at different mode.
---
be/src/common/config.cpp | 31 +++++++++++++++++--------------
be/src/common/config.h | 4 +---
be/src/service/doris_main.cpp | 7 +++++--
3 files changed, 23 insertions(+), 19 deletions(-)
diff --git a/be/src/common/config.cpp b/be/src/common/config.cpp
index a433b7ee8a1..f7f4cc99a4b 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);
-}
-
-void set_fuzzy_configs() {
- // random value true or false
- static_cast<void>(
- set_fuzzy_config("disable_storage_page_cache", ((rand() % 2) == 0)
? "true" : "false"));
- static_cast<void>(
- 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();
+Status set_fuzzy_configs() {
+ std::unordered_map<std::string, std::string> fuzzy_field_and_value;
+
+ // 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 5c298f906c1..6fcbecd8f71 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<std::vector<std::string>> 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 0217e272935..2b0c469bcd2 100644
--- a/be/src/service/doris_main.cpp
+++ b/be/src/service/doris_main.cpp
@@ -382,8 +382,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) && \
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]