Skip to content

Commit 3201159

Browse files
zhangstar333pull[bot]
authored andcommitted
[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.
1 parent 1d55d6e commit 3201159

3 files changed

Lines changed: 23 additions & 19 deletions

File tree

‎be/src/common/config.cpp‎

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1602,20 +1602,23 @@ void update_config(const std::string& field, const std::string& value) {
16021602
}
16031603
}
16041604

1605-
Status set_fuzzy_config(const std::string& field, const std::string& value) {
1606-
LOG(INFO) << fmt::format("FUZZY MODE: {} has been set to {}", field, value);
1607-
return set_config(field, value, false, true);
1608-
}
1609-
1610-
void set_fuzzy_configs() {
1611-
// random value true or false
1612-
static_cast<void>(
1613-
set_fuzzy_config("disable_storage_page_cache", ((rand() % 2) == 0) ? "true" : "false"));
1614-
static_cast<void>(
1615-
set_fuzzy_config("enable_system_metrics", ((rand() % 2) == 0) ? "true" : "false"));
1616-
// random value from 8 to 48
1617-
// s = set_fuzzy_config("doris_scanner_thread_pool_thread_num", std::to_string((rand() % 41) + 8));
1618-
// LOG(INFO) << s.to_string();
1605+
Status set_fuzzy_configs() {
1606+
std::unordered_map<std::string, std::string> fuzzy_field_and_value;
1607+
1608+
// if have set enable_fuzzy_mode=true in be.conf, will fuzzy those field and values
1609+
fuzzy_field_and_value["disable_storage_page_cache"] = ((rand() % 2) == 0) ? "true" : "false";
1610+
fuzzy_field_and_value["enable_system_metrics"] = ((rand() % 2) == 0) ? "true" : "false";
1611+
1612+
fmt::memory_buffer buf;
1613+
for (auto it = fuzzy_field_and_value.begin(); it != fuzzy_field_and_value.end(); it++) {
1614+
const auto& field = it->first;
1615+
const auto& value = it->second;
1616+
RETURN_IF_ERROR(set_config(field, value, false, true));
1617+
fmt::format_to(buf, "{}={}, ", field, value);
1618+
}
1619+
LOG(INFO) << fmt::format("FUZZY MODE IN BE: those variables have been changed: ({}).",
1620+
fmt::to_string(buf));
1621+
return Status::OK();
16191622
}
16201623

16211624
std::mutex* get_mutable_string_config_lock() {

‎be/src/common/config.h‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1364,9 +1364,7 @@ std::mutex* get_mutable_string_config_lock();
13641364

13651365
std::vector<std::vector<std::string>> get_config_info();
13661366

1367-
Status set_fuzzy_config(const std::string& field, const std::string& value);
1368-
1369-
void set_fuzzy_configs();
1367+
Status set_fuzzy_configs();
13701368

13711369
void update_config(const std::string& field, const std::string& value);
13721370

‎be/src/service/doris_main.cpp‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -382,8 +382,11 @@ int main(int argc, char** argv) {
382382
doris::init_thrift_logging();
383383

384384
if (doris::config::enable_fuzzy_mode) {
385-
LOG(INFO) << "enable_fuzzy_mode is true, set fuzzy configs";
386-
doris::config::set_fuzzy_configs();
385+
Status status = doris::config::set_fuzzy_configs();
386+
if (!status.ok()) {
387+
LOG(WARNING) << "Failed to initialize fuzzy config: " << status;
388+
exit(1);
389+
}
387390
}
388391

389392
#if !defined(__SANITIZE_ADDRESS__) && !defined(ADDRESS_SANITIZER) && !defined(LEAK_SANITIZER) && \

0 commit comments

Comments
 (0)