Repository navigation
Clear LLVM_PROFILE_FILE for manual clickhouse launches in test_server_reload - #101912
Conversation
Pre-PR Validation (session: cron:clickhouse-ci-task-worker:20260407-091500)a) Deterministic repro? b) Root cause explained? c) Fix matches root cause? d) Test intent preserved? e) Both directions demonstrated?
f) Fix is general? |
|
cc @azat — could you review this? It extends |
|
Workflow [PR], commit [830a8fc] Summary: ✅ AI ReviewSummaryThis PR fixes a flaky failure in ClickHouse Rules
Final Verdict
|
azat
left a comment
There was a problem hiding this comment.
I doubt that this is the correct fix, why do you think just ignoring errors is OK?
@groeneai Why? |
Change LLVM_PROFILE_FILE from %4m (merge-mode pool of 4) to %p (per-PID) inside Docker containers. Server and docker-exec'd client processes share the same container environment, causing file-lock races on the 4 merge-pool entries when multiple processes exit concurrently. Per-PID files eliminate the contention entirely. The CI merge step (merge_profraw_files / llvm-profdata merge -sparse) already handles arbitrary numbers of .profraw files.
27304ae to
905bda0
Compare
|
@azat You're right — filtering is wrong here. I've reworked the PR to fix the root cause. Why the conflicts happen: New fix: Changed Dropped the stderr filter entirely — the profiler errors should simply not happen anymore. |
|
@azat the issue is hidden in |
|
@alexbakharew Makes sense — CIDB confirms all 29 failures in the last 30 days are exclusively this test. Happy to defer if you have a test-specific fix. I can close this PR once yours is up. |
|
@groeneai the problem is that in test cases |
@groeneai fyi: |
…_reload In coverage builds, test_change_listen_host and test_reload_via_client launch clickhouse inside a container via `docker exec`. These processes inherit LLVM_PROFILE_FILE from the container environment and can select the same merge-pool slot (%4m) as the running server, causing file-lock races that produce "LLVM Profile Error: Failed to write file" on stderr. The test helper then treats this non-empty stderr as a query failure. Fix: pass `-e LLVM_PROFILE_FILE=` to `docker exec` for these manual launches, clearing the variable so the profiler is disabled for the short-lived client processes. The server's profiling is unaffected. Revert the previous %4m→%p change in cluster.py since the issue is specific to these two tests, not a global container problem.
|
@alexbakharew Done — implemented your fix direction. Changes in 830a8fc:
This clears the profiler env var for the manually-launched clickhouse-client processes inside the container, preventing them from racing with the server over the same merge-pool slots. The server's profiling remains unaffected. The fix is minimal — only the two test functions that use |
| "exec", | ||
| "-i", | ||
| "-e", | ||
| "LLVM_PROFILE_FILE=", |
There was a problem hiding this comment.
@alexbakharew is this OK? Then, where the profile file will be written? (if any) How we will collect coverage from it? (not a big deal for this specific test, but just wondering)
There was a problem hiding this comment.
It is the only one place where we execute the CH in docker manually. With our use case we can't afford switching from %4m mode to %p - the last option solves the issue.
For these 2 tests we just disable coverage collection for launching CH binary. It is disabled only in-place, general coverage collection is not affected.
So we just ignore the coverage for these 2 calls. I do not expect coverage degradation, but want to prove it once the CI is finished
|
@azat can we merge it? |
3e6118c
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes to CHANGELOG.md):
What this PR does
In coverage builds (
amd_llvm_coverage),test_change_listen_hostandtest_reload_via_clientlaunch clickhouse inside a container viadocker exec. These processes inheritLLVM_PROFILE_FILEfrom the container environment and can select the same merge-pool slot (%4m) as the running server, causing file-lock races that produceLLVM Profile Error: Failed to write file...File existson stderr. The test helper then treats this non-empty stderr as a query failure.Fix: Pass
-e LLVM_PROFILE_FILE=todocker execfor these manual launches, clearing the variable so the profiler is disabled for the short-lived client processes. The server's profiling is unaffected.Root cause (identified by @alexbakharew): The manually-launched clickhouse processes inside the container inherit the
LLVM_PROFILE_FILE=%4mpattern. With only 4 hash slots, the client can select the same pool_id the server already holds, causing a file conflict.Scope: Only the two affected tests are changed — the global
LLVM_PROFILE_FILEsetting incluster.pyis left at%4mas intended.CIDB data: 29 failures in 30 days, exclusively on
Integration tests (amd_llvm_coverage, 5/5), affecting 27 distinct PRs and 3 master runs.