Repository navigation
Fix stop_zookeeper not waiting for ZooKeeper JVM in test_keeper_zookeeper_converter - #102492
Merged
Merged
Conversation
…eper_zookeeper_converter
`stop_zookeeper` used `get_process_pid("zookeeper")` to wait for the
process to die, but `get_process_pid` uses the regex `'^[^ ]*zookeeper'`
which only matches the first word of the command line. The ZooKeeper Java
process starts with `java -Dzookeeper.log.dir=...`, so the first word
is `java`, not `zookeeper` — the regex never matched and the function
returned immediately without waiting.
Under resource-constrained environments (MSan), the JVM takes longer to
shut down after `zkServer.sh stop`. When `start_zookeeper` was called
later, the old process was still holding port 2181, causing the new JVM
to fail with exit code 1.
Fix by using `pgrep -f org.apache.zookeeper.server` to properly detect
the running ZooKeeper JVM process. Also increase start retries from
3 to 5 with 3-second delays as an additional safety net.
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
Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Contributor
|
Workflow [PR], commit [0025d52] Summary: ✅ AI ReviewSummaryThis PR fixes a flaky integration test shutdown/startup sequence for ZooKeeper in ClickHouse Rules
Final Verdict
|
The previous fix used `pgrep -f org.apache.zookeeper.server` inside a `bash -c ...` wrapper to detect the ZooKeeper JVM. But `pgrep -f` matches the full command line of every process, and the wrapping bash process itself has `org.apache.zookeeper.server` in its own argv — so pgrep always matched the shell running it, never returning empty, and the wait loop timed out after 60 seconds. Use the standard bracket-expression trick: the regex `[o]rg\.apache\.zookeeper\.server` matches the literal string `org.apache.zookeeper.server` but does not match its own pattern `[o]rg\.apache\.zookeeper\.server` that appears in the shell's argv. CI report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=102492&sha=e220a72e8388401e2ebe63cd04a70c18c6c5f9d6&name_0=PR&name_1=Integration%20tests%20%28amd_asan_ubsan%2C%20flaky%29 Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
This was referenced Apr 27, 2026
pull Bot
pushed a commit
to Mu-L/ClickHouse
that referenced
this pull request
Apr 28, 2026
…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]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
stop_zookeeperusedget_process_pid("zookeeper")to wait for the process to die, butget_process_piduses the regex'^[^ ]*zookeeper'which only matches the first word of the command line. The ZooKeeper Java process starts withjava -Dzookeeper.log.dir=..., so the first word isjava, notzookeeper— the regex never matched and the function returned immediately without actually waiting for the process to exit.Under resource-constrained environments (MSan), the JVM takes longer to shut down after
zkServer.sh stop. Whenstart_zookeeperwas called later, the old process was still holding port 2181, causing the new JVM to fail with exit code 1.Fix by using
pgrep -f org.apache.zookeeper.serverto properly detect the running ZooKeeper JVM process. Also increase start retries from 3 to 5 with 3-second delays as an additional safety net.CI report: 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
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.4.1.1054