gavinchou commented on code in PR #45394: URL: https://github.com/apache/doris/pull/45394#discussion_r1896329875
########## cloud/src/common/configbase.cpp: ########## @@ -328,4 +395,50 @@ bool init(const char* conf_file, bool fill_conf_map, bool must_exist, bool set_t return true; } +bool do_set_config(const Register::Field& feild, const std::string& value, bool need_persist, + Properties& props) { + UPDATE_FIELD(feild, value, bool, need_persist); + UPDATE_FIELD(feild, value, int16_t, need_persist); + UPDATE_FIELD(feild, value, int32_t, need_persist); + UPDATE_FIELD(feild, value, int64_t, need_persist); + UPDATE_FIELD(feild, value, double, need_persist); + { + // add lock to ensure thread safe + std::lock_guard<std::mutex> lock(mutable_string_config_lock); + UPDATE_FIELD(feild, value, std::string, need_persist); + } + return false; +} + +bool set_config(const std::string& field, const std::string& value, bool need_persist, + const std::string& custom_conf_path) { + auto it = Register::_s_field_map->find(field); + if (it == Register::_s_field_map->end()) { + return false; + } + if (!it->second.valmutable) { + return false; + } + + Properties props; + auto set_conf_func = [&]() { + if (!do_set_config(it->second, value, need_persist, props)) { + std::cerr << "not supported to modify: " << field << "=" << value << std::endl; + return false; + } + return true; + }; + + if (need_persist) { + // lock to make sure only one thread can modify the be_custom.conf + std::lock_guard<std::mutex> l(conf_persist_lock); + if (!set_conf_func()) { + return false; + } + return props.dump(custom_conf_path); Review Comment: it seems overwrite all the file and remove all comments -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org