Repository navigation
Fix flaky test_keeper_session_refuse_stale_server - #109037
alexey-milovidov merged 1 commit into
Conversation
The test restarts all three Keeper containers, then waits for them to come back. stop_zookeeper_nodes() stops them serially, but start_zookeeper_nodes() went through process_integration_nodes(), which ran one `docker compose start <node>` process per node concurrently (ThreadPoolExecutor) against the same compose project. Concurrent `docker compose` invocations on one project race on the project's shared state: on a loaded CI runner (integration tests run with -n workers), the start of one node can be silently dropped. On the amd_msan failure the Keeper's graceful stop overran docker's stop timeout and was SIGKILLed (exit 137); the three concurrent `docker compose start` processes then fired within 2 ms of that stop returning, and dockerd received no /start for zoo3 (it did for zoo1/zoo2). zoo3 never came back, so wait_zookeeper_to_start() timed out after 180 s and raised the generic "Cannot wait ZooKeeper container ... iptables-nft" exception. The same latent race affected kill_zookeeper_nodes(). Use a single `docker compose <action> <node1> <node2> ...` invocation instead of N concurrent ones. This is the pattern the framework already uses for startup (a single `docker compose up -d`); compose parallelizes the services internally, so there is no loss of parallelism and no shared-project race. Verified via the CI report for PR ClickHouse#108074 (amd_msan 5/8): dockerd received zoo3's container /json inspects but no /start, while zoo1/zoo2 got /start; docker.log shows "zoo3-1 exited with code 137" with no subsequent restart. Co-Authored-By: Claude Opus 4.8 <[email protected]>
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-worker-slot-1:20260701-080800 |
|
cc @maxknv — could you review this? It fixes a concurrent- |
|
Workflow [PR], commit [9f90342] Summary: ✅ AI ReviewSummaryThis PR changes Missing context / blind spots
Final Verdict✅ No inline findings to post. The change is small, scoped to the integration-test framework, and the failure behavior still propagates through |
…per_session_refuse_stale_server Fix flaky test_keeper_session_refuse_stale_server
…restarting them `test_keeper_session_refuse_stale_server` failed with `Cannot wait ZooKeeper container` (kazoo `ValueError: bad hostname`): after the test's own restart one ZooKeeper node was never started again and had no IP. On Docker Engine 27.0.3 (the integration runner image), `stop` and `kill` return when the exit handler marks the container stopped, but the handler publishes that state to the view behind `GET /containers/json` only after two fsync'd config writes (moby/moby#50133, fixed in Engine 28.3). `docker compose start` lists the project once and skips every container listed as running, so when its list lands in that gap the last-stopped node gets no `POST /start` and compose still exits 0. Measured in two CI jobs: the list came ~60 ms after zoo3's stop returned and ~100 ms before its stopped state was visible. ClickHouse#109037 made the restart a single compose call, which did not help: the skip comes from the stale list, not from concurrent compose commands. `wait_integration_nodes_stopped` polls that same list (the project label, the `State` field compose checks) after `stop_zookeeper_nodes` and after `process_integration_nodes` stop/kill, and raises with the container names if they are still listed as running after 30 s. Inspect is not used as the oracle because it takes the container lock and reports `exited` before the list does. On a fixed Engine the wait is one list call. Validated in the CI runner image (Docker 27.0.3, compose 2.29.7) as a nested dockerd with an fsync delay injected: the real harness methods failed 17/20 (stop) and 19/20 (single-node kill) before, 0/20 and 0/20 after, and 19/20 again with the wait disabled. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
...
Description
Fixes flaky
test_keeper_session_refuse_stale_server(requested by @alexey-milovidov on #108074).The test restarts all three Keeper containers, then waits for them to come back.
stop_zookeeper_nodes()stops them serially, butstart_zookeeper_nodes()went throughprocess_integration_nodes(), which ran onedocker compose start <node>process per node concurrently (aThreadPoolExecutor) against the same compose project.Concurrent
docker composeinvocations on one project race on the project's shared state: on a loaded CI runner (integration tests run with-nworkers) the start of one node can be silently dropped.On the failing amd_msan run the Keeper's graceful stop overran docker's stop timeout and was SIGKILLed (exit 137); the three concurrent
docker compose startprocesses then fired within ~2 ms of that stop returning, and dockerd received no/startfor zoo3 (it did for zoo1/zoo2). zoo3 never came back, sowait_zookeeper_to_start()timed out after 180 s and raised the genericCannot wait ZooKeeper container ... iptables-nftexception attest.py:73. The same latent race affectedkill_zookeeper_nodes().Fix: use a single
docker compose <action> <node1> <node2> ...invocation instead of N concurrent ones. This is the pattern the framework already uses for startup (a singledocker compose up -d); compose parallelizes the services internally, so there is no loss of parallelism and no shared-project race.CI failure this addresses (Integration tests (amd_msan, 5/8), PR #108074, commit
817d237610a2d554f27994aedfdd07de1fef0bdc):https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=108074&sha=817d237610a2d554f27994aedfdd07de1fef0bdc&name_0=PR&name_1=Integration%20tests%20%28amd_msan%2C%205%2F8%29
Evidence from that report: dockerd received zoo3's container
/jsoninspects but no/startwhile zoo1/zoo2 got/start;docker.logshowszoo3-1 exited with code 137with no subsequent restart; the gw0 log then pollszoo3: bad hostnamefor the full 180 s.No related open issue found (searched by test name,
process_integration_nodes,start_zookeeper_nodes).Version info
26.7.1.370(included in26.7and later)