Repository navigation
Add SIGKILL fallback in test_keeper_zookeeper_converter::stop_zookeeper - #103600
alexey-milovidov merged 2 commits into
Conversation
…LL fallback `zkServer.sh stop` in ZooKeeper 3.6.3 only sends a single SIGTERM, removes the PID file, and returns — it neither waits for the JVM to actually exit nor escalates to SIGKILL. The test's `stop_zookeeper` therefore polled `pgrep` for up to 60 seconds and raised `Failed to stop ZooKeeper in 60 secs` if the JVM had not finished its shutdown hooks by then. Under sanitizer-heavy CI builds (MSan in particular) JVM shutdown hooks can occasionally exceed 60 seconds, leading to chronic flakiness on master and PR runs (cf. PR ClickHouse#102492 which fixed the broken `pgrep` regex and added retries to `start_zookeeper`). The genuine ZooKeeper JVM in this test exists only to populate test data for the `clickhouse keeper-converter` tool — we do not test the JVM itself and a clean shutdown is unnecessary. Add a SIGKILL fallback that fires after SIGTERM does not stop the JVM in 60 seconds, so the test can never fail on a slow or hung JVM shutdown. The bracket trick `[o]rg.apache.zookeeper.server` in the `pgrep` / `pkill` pattern is preserved to keep the kill from matching its own shell process. Recent CI runs after PR ClickHouse#102492 (merged 2026-04-19): zero failures of either `test_acls[True]` or `test_acls[False]` over ~27000 runs in 8 days. This change is a proactive hardening so future sanitizer load can never regress that streak. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
|
Pre-PR validation gate (session id: cron:clickhouse-ci-task-worker:20260427-091500) a) Deterministic repro? No deterministic repro exists today — the test has been clean for 8 days since #102492 merged (~27,000 runs, zero failures). This PR is proactive hardening of the same fragile shutdown path that produced the chronic b) Root cause explained? Yes. ZooKeeper 3.6.3's c) Fix matches root cause? Yes. The fix adds a SIGKILL escalation after the existing 60s SIGTERM wait, which is exactly the missing piece in d) Test intent preserved? Yes. The genuine ZooKeeper JVM is only there to populate test data for e) Demonstrated in both directions? Partial. I cannot reproduce the original failure locally without an MSan binary (the failure was load-induced and stopped reproducing 8 days ago), but I verified the new SIGKILL path independently inside f) Fix is general, not a narrow patch? Yes. The same |
|
cc @alexey-milovidov @CurtizJ @azat — could you review this? Per @alexey-milovidov's directive on #100941 (comment) to fix |
|
Workflow [PR], commit [f38816d] Summary: ✅ AI ReviewSummaryThis PR hardens ClickHouse Rules
Final Verdict
|
@groeneai how is JVM connected to our MSan builds? |
|
@antonio2368 good catch — that wording is imprecise, sorry. The mechanism is CPU/scheduling pressure, not direct instrumentation:
So the path is indirect: MSan slows ClickHouse → ClickHouse starves the co-scheduled JVM → JVM shutdown stretches past 60 s. The fix itself doesn't depend on the mechanism — the genuine ZK JVM is only there to populate test data for I'll update the PR description to reflect this more accurately. |
Per directive at #100941 (comment)
(fix
test_keeper_zookeeper_converter/test.py::test_acls[True]flakiness in a separate PR).zkServer.sh stopin the ZooKeeper 3.6.3 binary used by the test sends a singleSIGTERM to the JVM, removes the PID file, and returns — it does not wait for
the JVM to actually exit and has no SIGKILL fallback (see
zkServer.shupstream).The test's
stop_zookeeperpollspgrepfor up to 60 seconds and raisesFailed to stop ZooKeeper in 60 secsif the JVM has not finished its shutdownhooks by then.
Under sanitizer-heavy CI builds (MSan in particular), the ZooKeeper JVM and the
MSan-instrumented ClickHouse server share the same Docker container and the
same CPU. MSan only instruments compiled C/C++ code at the LLVM IR level — the
JVM itself is not sanitizer-instrumented, the OpenJDK
javabinary and theZooKeeper bytecode run the same way they do in non-sanitizer builds. But the
~2–10× CPU slowdown MSan adds to ClickHouse leaves the JVM with much less
scheduler share. JVM shutdown hooks (log flushes, snapshot finalization, file
close, ZK-internal teardown) are largely synchronous, and under that scheduler
pressure they can occasionally exceed the 60-second
pgreppoll. This is thedominant chronic-flakiness mode this test exhibited before #102492 (the
pgrepregex fix andstart_zookeeperretry loop).Recent CIDB shows zero
test_aclsfailures across ~27,000 runs in the 8 dayssince #102492 merged, but the historical pattern is sporadic and sanitizer
load can push JVM shutdown over the 60s line at any time.
The genuine ZooKeeper JVM in this test exists only to populate test data for
the
clickhouse keeper-convertertool — we do not test the JVM itself and aclean shutdown is unnecessary. Add a SIGKILL fallback that fires after SIGTERM
does not stop the JVM in 60 seconds, so the test can never fail on a slow or
hung JVM shutdown. The bracket trick
[o]rg.apache.zookeeper.serverin thepgrep/pkillpattern is preserved (and now factored into a constant) tokeep the kill from matching its own shell process.
CIDB sample failures showing the addressed pattern:
https://s3.amazonaws.com/clickhouse-test-reports/json.html?REF=master&sha=00ecef1c87cfebeb52a024307b0a76a68518fb53&name_0=MasterCI&name_1=Integration%20tests%20%28amd_msan%2C%206%2F6%29
Verification
python3 -m ci.praktika run "integration" --test "test_keeper_zookeeper_converter/test.py::test_acls" --count 3— 6/6 passes locally.clickhouse/integration-test:latest:pgrep -f '[o]rg\.apache\.zookeeper\.server'matches the running JVM.pkill -9 -f '[o]rg\.apache\.zookeeper\.server'kills the JVM and does not match itself.pgrepreturns nothing.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.5.1.148