Repository navigation
Conversation
…action process_integration_nodes issued one `docker compose <action> <node...>` and treated rc=0 as proof that every requested node reached the requested state, logging `%sed ... nodes: %s` unconditionally. That is not proof. Measured on compose 2.29.7, the version CI pins (ci/docker/integration/runner/Dockerfile), against a 3-service project: `start` on a service that is `exited(7)` prints both `Starting` and `Started`, returns 0, and leaves the service `exited(7)`; `start` on an already-running service omits it from the output entirely, also with 0. Neither the exit code nor the printed output distinguishes success from a silent skip. test_keeper_session_refuse_stale_server::test_session_refused_on_stale_keeper hit this on PR ClickHouse#104437's `Integration tests (amd_tsan, 3/6)` at head 7de491b. zoo3's graceful stop overran `stop_grace_period: 5s` and it was SIGKILLed (exit 137, hasBeenManuallyStopped=true, so `restart: always` correctly did not resurrect it); the following `docker compose start zoo1 zoo2 zoo3` returned 0 having issued a `/start` call for zoo1 and zoo2 only. dockerd `/start` POST counts for the whole job: zoo1 2, zoo2 2, zoo3 1, and zoo3's single one is fixture startup. Keeper logs corroborate: `Starting ClickHouse` appears twice for keeper1 and keeper2, once for keeper3. The harness logged `Started zookeeper nodes: (zoo1, zoo2, zoo3)`, then polled a container with no IP for 180 s (321 `bad hostname` lines) and raised a message naming `iptables-nft` on a run where the host network was demonstrably fine. Three separate reporters read the failure as an infrastructure problem. The listing race itself did not reproduce, here or during ClickHouse#109037, so this change does not try to fix it. It removes the amplifier: any compose-side omission, this one or a future one, now fails immediately and correctly attributed instead of becoming a success line plus a 180 s timeout at an unrelated frame. The oracle is `State.Status`, not `State.Running`, because Running is also true for `paused` and `restarting` (measured: paused -> Status=paused Running=true; restarting -> Status=restarting Running=true), which are exactly two states a `start` must not accept. The status is read after the action, because a docker-py handle caches its state and one held across the call reports the old value (measured: a handle fetched while up still reported `running` after a real `compose stop`; only a reload or a fresh fetch reported `exited`). This is not a regression of ClickHouse#109037, which replaced N concurrent compose processes with one atomic invocation and is still in place: that fixed a concurrent-compose race, whereas this omission happens inside a single invocation. Not in scope: raising `stop_grace_period` (the test wipes logs and snapshots before restarting, so a SIGKILLed keeper is harmless, and an `exited(137)` service was measured to start fine); retrying the compose call (it would mask the signal this check exists to surface); routing stop_zookeeper_nodes, which uses a serial per-node loop, through this seam.
The three properties that make the post-condition check meaningful are all invisible to the suites that use the seam, because every one of them drives only the success path: a check that silently became a no-op would keep all eight of them green. The arms bind the shipped ClickHouseCluster methods to a stub rather than copying their logic, in the mocked-harness shape tests/integration/ test_cluster_waiters already uses for helpers/cluster.py, so they need no Docker and no cluster and run in 0.09s. Four mutants were checked: an early-return no-op reddens all seven, State.Running reddens the paused and restarting arms, a handle cached across the compose call reddens the freshness arm, and a fixed node set reddens scoping, freshness and the action matrix. A test asserting that compose lied at the docker layer stays out of scope: it would have to fabricate the dockerd listing race, which did not reproduce.
The post-condition check added to process_integration_nodes was already pinned by seven mocked arms. Its sibling half, the diagnostic wait_zookeeper_nodes_to_start builds on timeout and the describe_container_state helper it calls, was not: reverting the message to the old bare iptables-nft string, dropping the per-iteration blocking_node assignment so the message names the wrong node, or unguarding either lookup in the helper so a diagnostic masks the failure it exists to report, all left every arm green. That half is what a reporter reads, and misreading it as a firewall problem is what this change exists to prevent. Six arms cover it, on a faked clock so the whole budget elapses instantly and the elapsed figure the message reports is exact: message contents, the named node being the one that blocked rather than the first or last of the request, subset scoping, each of the helper's two except branches failing without the reader losing the ZooKeeper failure, and a negative control that returns without spending the budget. A second stub class supplies only the five attributes the waiter and its helper touch, and binds the shipped methods, so the arms track helpers/cluster.py rather than a copy. Nine mutants confirm the arms bite, verdicts read from junit-xml: the five above plus the four from the check, which redden exactly the arms they did before the file grew. No source line changes.
Internal second-model review (click to expand)Three review rounds on this change: two cold reviews that each bounced it back for
Also checked and clear: the diff removes the old exception text, and nothing in the Session id: cron:clickhouse-review-slot-8:20260824-023500 |
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-impl-slot-4:20260824-021200 |
|
Workflow [PR], commit [5c8428f] Summary: ❌
AI ReviewSummaryThis PR hardens the integration harness around Missing context / blind spots
Final Verdict✅ No blocking review findings on the current head. |
|
cc @mstetsyuk, could you review this? |
The shared docker-py client is built with timeout=600, sized for image pulls. The diagnostic added to wait_zookeeper_nodes_to_start makes two fresh Docker requests (the container inspect, and the address lookup behind it) on a path where the waiter's own 60/180s budget is already spent, so on a slow or wedged daemon it could hold the caller for up to 20 minutes past the deadline it advertises. Measured against a listener that accepts and never replies: describing a node returned in 10.0s with the bound (two 5s requests), and was still blocked at a 25s observation cap without it. docker-py reads api.timeout per request, so lowering it for the duration of the description bounds both calls; the previous value is restored so unrelated callers of the shared client, including image pulls, keep the long timeout. Six arms in test_cluster_waiters pin the bound, its restoration on both the succeeding and failing paths, and that a client with no request layer is still described. Five mutants cover the ways the bound can silently stop working (removed, leaked, applied to only one of the two calls, widened to the shared value, or made the thing that breaks the diagnostic); each reddens only its own arm. The nine mutants from the earlier rounds still redden exactly the arms they did before, so the existing coverage is unaffected.
check_integration_nodes_state inspects each requested node through the shared docker client that ClickHouseCluster.start builds with timeout=600, which is sized for image pulls. That call is on the main path, so an unresponsive daemon held start_zookeeper_nodes / kill_zookeeper_nodes for up to 600s per node before the ZooKeeper waiter even started. Three nodes reach 1800s, past the 900s per-test timeout in tests/integration/pytest.ini, so the run was killed before the "Cannot inspect" message it exists to produce was ever emitted. Wrap the inspect in the existing bounded_docker_requests helper with its own constant rather than reusing CONTAINER_DESCRIBE_TIMEOUT. The describe path is best effort and only shapes the text of a failure that already happened, so 5s is right there; this call decides whether a test passes, so expiring early would turn a passing run red. Measured worst single inspect against a real daemon: 1.3ms idle, 39ms under container churn, 76ms under 96 API threads plus 16 start/kill loops, and 1.92s under 256 concurrent inspects. 30s keeps a 15.7x margin over that worst case while capping three nodes at 90s, a tenth of the per-test budget. Verified against a TCP listener that accepts and never replies: the unbounded code stayed blocked at a 45s observation cap while the bounded form raised in 30.03s, with the daemon confirming a connection in both arms so neither returned without reaching the inspect. On a real daemon the passing path takes 1.1ms, a stopped container is still rejected, and the shared timeout reads 600 again afterwards on both paths. Six new arms in test_cluster_waiters/test_integration_node_state.py pin the per-node bound, its width relative to the describe bound, restoration on the passing and both failing paths, and a client with no request layer. Each of six mutants (bound removed, widened to 600, narrowed to 5, only the first node bounded, restore dropped, guard removed) reddens only its mapped arm.
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
Only the stripped binary is compared: the official master build keeps debug symbols while PR builds strip them, so the other binaries differ by construction. Compile time of recompiled translation units6 translation units recompiled, 4 s compile time in total, 6 of them have a recent master baseline. |
CI finish ledger - 5c8428fEvery failure below has an owner: a fixing PR (ours or external), or a full-effort fix task
Not caused by this PR: the diff is Gate (a) 0 of 177 checks incomplete; gate (b) Session id: cron:our-pr-ci-monitor:20260824-103000 |
|
Fixing PR for the |
Related: #104437
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
...
Description
test_keeper_session_refuse_stale_server::test_session_refused_on_stale_keeperfailed on#104437's
Integration tests (amd_tsan, 3/6)with
Cannot wait ZooKeeper container (probably it's a iptables-nft issue)after a 180 s timeout,on a host whose network was fine. From the artifacts: zoo3's graceful stop overran
stop_grace_period: 5sand it was SIGKILLed, thendocker compose start zoo1 zoo2 zoo3returned0 having issued a
/startcall for zoo1 and zoo2 only (dockerd/startPOST counts: zoo1 2,zoo2 2, zoo3 1, and zoo3's is fixture startup).
process_integration_nodesloggedStarted zookeeper nodes: (zoo1, zoo2, zoo3), so the failure surfaced 180 s later at an unrelatedframe, blaming the firewall.
Neither the exit code nor the printed output distinguishes success from a silent skip. On compose
2.29.7 (CI's pin) I measured
startprinting bothStartingandStartedfor a service thatstayed
exited(7), returning 0. Only the daemon's state is reliable.process_integration_nodesnow inspects each requested node after the compose call and raises ifits
State.Statusis not what the action asked for, naming the node, container, status and exitcode.
State.Runningis not usable here: it is also true forpausedandrestarting. The read isfresh, since a docker-py handle held across the call reports the old value.
wait_zookeeper_nodes_to_startreports the blocking node, its resolved IP (empty is the tell),container status and elapsed time, with
iptables-nftno longer all it says.I could not reproduce the compose/dockerd race itself, here or in #109037; the artifacts are the
evidence for the failure, the measurements above for the mechanism this check asserts against.
#109037 made the invocation atomic, fixing a concurrent-compose race; this skip is inside one
invocation. Out of scope:
stop_zookeeper_nodesbypasses this seam with a serial per-node loop.Requested by @ bacek; no open issue found for it.
Validation
All 8 suites using these wrappers pass:
test_keeper_session_refuse_stale_server,test_check_table(killpath),test_inserts_with_keeper_retries,test_read_only_table,test_reload_zookeeper,test_remove_stale_moving_parts,test_replicated_user_defined_functions,test_replicated_users. The last four include thesubset-starting callers (
['zoo2','zoo3'],['zoo2']) that a wrongly scoped check would break.Target test 20/20 on repeat.
Both directions on the real keeper fixture, with the victim not running after a
successful compose
start: before the change the wait burns its whole budget and blamesiptables-nft; after it, the failure is immediate (0.2 s) and names the node. Negative controlwith every node genuinely up stays silent.
test_cluster_waiters/test_integration_node_state.pyadds 13 arms that bind the shipped methodsand run in 0.1 s with no Docker. Seven cover the check: message contents, a negative control,
pausedandrestartingrejected forstart, the read happening after the action in bothdirections, subset scoping, the action/status matrix. Six cover the diagnostic, on a faked clock:
message contents, the named node being the one that blocked rather than the first or last, subset
scoping, each of the helper's two lookups failing without masking the reported failure, and a
negative control that returns without spending the budget. None of the 8 suites can see any of
it, since each drives only the success path.
Nine mutants confirm the arms bite: an early-return no-op check reddens all seven of its arms; a
State.Runningoracle reddenspausedandrestarting; a handle cached across the actionreddens freshness; a fixed node set reddens scoping, freshness and the matrix; the old message
reddens five diagnostic arms; dropping the blocking-node tracking reddens three; unguarding
either lookup reddens its own arm; removing the early return reddens the negative control.
Workflow [PR]
Sync PR [sync-upstream/pr/116044]