[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.
This commit is contained in:
@ -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<std::string, std::string> fuzzy_field_and_value;
|
||||
|
||||
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();
|
||||
// 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() {
|
||||
|
||||
@ -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);
|
||||
|
||||
|
||||
@ -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) && \
|
||||
|
||||
Reference in New Issue
Block a user