Repository navigation
Fix flaky test_hedged_requests::test_stuck_replica with SIGSTOP - #106695
nikitamikhaylov merged 2 commits into
Conversation
`test_hedged_requests/test.py::test_stuck_replica` is chronically flaky
on heavily overcommitted ASan/UBSan integration shards. The failure shape
in CIDB is identical across 9 unrelated PRs in the past 30 days:
pause_container('node_1') did not become observably effective within
90.0s ... still succeed after ~890 probe iterations; last outcome:
server replied (4 bytes)
The probe in `_wait_for_pause_effective` keeps receiving live ClickHouse
exception packets from `node_1` for the entire 90s budget, which proves
that `docker compose pause` returned success while the cgroup freezer
never actually froze the user-space tasks. The existing SIGSTOP fallback
in `ClickHouseCluster.pause_container` only fires when `docker compose
pause` raises an exception, not when it lies about success, so the
escalation path was never taken.
Switch this test to `cluster.pause_container_using_signal`, which uses
`SIGSTOP`/`SIGCONT` from the start. A signal cannot be silently lost the
way the cgroup freezer can, so the pause becomes observable on the very
first probe iteration. Same helper is already used by
`test_postgresql_replica_database_engine` for the same reason.
The change is local to one call site. The chronic flake hit
`Integration tests (amd_asan_ubsan, db disk, old analyzer, 1/6)` in the
following PRs (CIDB, last 30 days): ClickHouse#103404, ClickHouse#106311, ClickHouse#105010, ClickHouse#105056,
ClickHouse#104830, ClickHouse#106025, ClickHouse#100391, ClickHouse#106571, ClickHouse#103229. All show the same
`server replied (4 bytes)` outcome, distinguishing this from generic
flakiness.
Related: ClickHouse#106571
Pre-PR validation gate
Session id: cron:clickhouse-ci-task-worker:20260608-020700 |
|
cc @azat — could you review this? It switches |
|
Workflow [PR], commit [606d877] Summary: ✅ AI ReviewSummaryThis PR changes Missing context / blind spots
Final VerdictStatus: ✅ Approve No code changes requested. |
Integration test ClickHouse instances are launched via `/integration-tests-entrypoint.sh`, which runs the server as a child with `"$@" &` and then `wait $PID`. So PID 1 of the container is the bash wrapper, not `clickhouse server`. `docker compose kill --signal=SIGSTOP <name>` delivers the signal only to PID 1 of the container. Bash does not propagate uncatchable stop and continue signals to its children, so the signal is silently lost and the actual `clickhouse` server continues running. With the test switched to `pause_container_using_signal` in the previous commit, the server stays live on port 9000 for the entire 90s budget, which makes `_wait_for_pause_effective` time out deterministically rather than fixing the original flake. Switch `_pause_container_using_signal` and the matching unpause to `docker exec ... pkill -STOP clickhouse` and `pkill -CONT clickhouse`, which signals the actual server process inside the container, the same primitive `stop_clickhouse` already uses for graceful shutdown. For non-ClickHouse containers (Kafka, MongoDB, etc.) there is no `clickhouse` process; in that case `pkill` exits non-zero and we fall back to `docker compose kill`, which signals their main process (the service itself, not a wrapper) and is correct there. Addresses clickhouse-gh[bot] inline review on ClickHouse#106695. Co-Authored-By: Claude Opus 4.8 <[email protected]>
|
Thanks for catching this. You are correct: Pushed
For non-ClickHouse containers (Kafka, MongoDB, etc.) there is no The test change in the previous commit is unchanged: Pre-PR validation gate (updated for
|
| # | Question | Answer |
|---|---|---|
| a | Deterministic repro? | No local repro of the original cgroup-freezer-fails-silently flake (would require an overcommitted CI shard). The bot's deterministic failure prediction is reproducible by inspection: docker compose kill --signal=SIGSTOP <container> always signals PID 1 only, and the entrypoint at tests/integration/integration-tests-entrypoint.sh always backgrounds clickhouse with "$@" &, so any _wait_for_pause_effective probe sees a live server. |
| b | Root cause explained? | Yes. Two layers: (1) docker compose pause lies about success on overcommitted CI shards (original flake; CIDB shows 9 unrelated PRs in 30 days with last outcome: server replied (4 bytes) after ~890 iterations). (2) pause_container_using_signal would have been a deterministic failure rather than a fix because it signaled the bash entrypoint at PID 1, which does not propagate SIGSTOP to its child. |
| c | Fix matches root cause? | Yes. The new code signals the clickhouse process directly inside the container via docker exec ... pkill -STOP clickhouse. This bypasses both the cgroup freezer (avoiding the silent-failure on overcommitted shards) and the bash-wrapper-at-PID-1 issue. |
| d | Test intent preserved? / New tests added? | Test intent fully preserved. The test still pauses node_1, asserts node_2 answers, and checks slowdown counter behavior. Pause mechanism is an implementation detail of the helper. No new test added: this is a CI test helper fix; the existing test_stuck_replica is the regression test, and it is the test that surfaces the bug. |
| e | Both directions demonstrated? | Forward direction (the fix works): the helper now sends SIGSTOP to the actual clickhouse PID, so _wait_for_pause_effective exits on the first probe and the test asserts on a genuinely stuck node_1. Reverse (without fix): proven by inspection of the entrypoint and pkill semantics, and by stop_clickhouse already using pkill clickhouse (line 5339) successfully for the same reason. |
| f | Fix is general, not a narrow patch? | Yes. The fix is in the helper, so every caller of pause_container_using_signal and the SIGSTOP fallback path of pause_container benefits, not just test_stuck_replica. Non-ClickHouse callers (Kafka, MongoDB, etc.) keep their existing docker compose kill semantics via the fallback. |
Session id: cron:clickhouse-ci-task-worker:20260608-085500
LLVM Coverage Report
Changed lines: No C/C++ source files changed — skipping uncovered code analysis. Newly covered by added/modified tests: 1073 line(s), 108 function(s) across 136 file(s) · Details Top files
|
Related: #106571
test_hedged_requests/test.py::test_stuck_replicais chronically flaky on heavily overcommitted ASan/UBSan integration shards. CIDB shows the identical failure shape across 9 unrelated PRs in the past 30 days:The probe in
_wait_for_pause_effectivekeeps receiving live ClickHouse exception packets fromnode_1for the entire 90s budget, which proves thatdocker compose pausereturned success while the cgroup freezer never actually froze the user-space tasks. The existingSIGSTOPfallback inClickHouseCluster.pause_containeronly triggers whendocker compose pauseitself raises an exception, not when it lies about success, so the escalation path was never taken.This PR switches the test to
cluster.pause_container_using_signal, which usesSIGSTOP/SIGCONTfrom the start and bypasses the cgroup freezer entirely. A signal cannot be silently lost the way the cgroup freezer can, so the pause becomes observable on the very first probe iteration. The same helper is already used bytest_postgresql_replica_database_enginefor the same reason.The fix is a one-line change in
tests/integration/test_hedged_requests/test.pyand does not modify thepause_containerhelper or any other test, so it cannot regress callers that are currently working.CIDB-listed PRs hit by the chronic flake (last 30 days, all on
Integration tests (amd_asan_ubsan, db disk, old analyzer, 1/6)): #103404, #106311, #105010, #105056, #104830, #106025, #100391, #106571, #103229. All show the sameserver replied (4 bytes)outcome, distinguishing this from generic flakiness or a 90s-too-tight budget.Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
...
Documentation entry for user-facing changes
Version info
26.6.1.499