github-actions[bot] commented on code in PR #65921:
URL: https://github.com/apache/doris/pull/65921#discussion_r3631399577


##########
be/benchmark/benchmark_main.cpp:
##########
@@ -52,6 +59,35 @@
 
 namespace doris { // change if need
 
+static bool init_benchmark_config(const char* executable) {
+    std::vector<std::filesystem::path> candidates;
+    if (const char* doris_home = std::getenv("DORIS_HOME"); doris_home != 
nullptr) {
+        candidates.emplace_back(std::filesystem::path(doris_home) / "conf" / 
"be.conf");
+    }
+    candidates.emplace_back(std::filesystem::current_path() / "conf" / 
"be.conf");
+    const auto executable_dir = 
std::filesystem::absolute(executable).parent_path();
+    candidates.emplace_back(executable_dir / ".." / ".." / "conf" / "be.conf");
+    candidates.emplace_back(executable_dir / ".." / ".." / ".." / "conf" / 
"be.conf");
+    for (const auto& candidate : candidates) {
+        if (!std::filesystem::exists(candidate)) {
+            continue;
+        }
+        if (std::getenv("DORIS_HOME") == nullptr) {
+            const auto inferred_home = 
candidate.parent_path().parent_path().string();
+            // be.conf contains paths relative to DORIS_HOME. Keep standalone 
benchmark launches
+            // equivalent to build/test scripts after locating the same 
repository config.
+            if (::setenv("DORIS_HOME", inferred_home.c_str(), 0) != 0) {
+                return false;
+            }
+        }
+        // Mutable config storage is populated by config::init. Reader 
benchmarks must use the
+        // production defaults because zero-initialized safety limits reject 
every valid footer.
+        return config::init(candidate.c_str(), false);

Review Comment:
   `config::init()` is not read-only here. In Cloud mode it calls 
`set_config("enable_file_cache", "true", /*need_persist=*/true, 
/*force=*/true)`, which writes `${custom_config_dir}/be_custom.conf`. Thus even 
`benchmark_test --benchmark_list_tests` can mutate the configuration of the 
`DORIS_HOME` selected above. Please populate the required benchmark defaults 
through a non-persisting initialization path rather than invoking the 
production initializer with this side effect.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to