Skip to content

Retry the forced kill in the integration cluster shutdown - #123638

Merged
alexey-milovidov merged 1 commit into
ClickHouse:masterfrom
groeneai:retry-compose-kill-in-cluster-shutdown
Oct 3, 2026
Merged

alexey-milovidov merged 1 commit into
ClickHouse:masterfrom
groeneai:retry-compose-kill-in-cluster-shutdown

Conversation

@groeneai

@groeneai groeneai commented Oct 3, 2026 •

Copy link
Copy Markdown
Collaborator

Related: #120632

Changelog category (leave one):

  • CI Fix or Improvement (changelog entry is not required)

Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):

...

Description

ClickHouseCluster.shutdown() runs docker compose stop and, if that fails, docker compose kill. A failure of the fallback escapes shutdown(): a module whose tests all passed is reported red at teardown, and the instance log scans, down --volumes and cleanup() are skipped, so the project leaks.

Failing job:
Integration tests (amd_asan_ubsan, db disk, targeted)
on #120632
(report).
Every test of test_hive_query passed; the teardown error was charged to its last test. From the job's docker-in-docker.log:

  1. hdfs1 needed about 16 s to exit after SIGKILL, more than the ~14 s dockerd waits, so stop failed with tried to kill container, but did not receive an exit event and left minio1, proxy1 and proxy2 running.
  2. compose kill still listed hdfs1, which exited about 0.1 s before its kill arrived. That kill got container ... is not running and compose kill exited 1, although the other three containers were killed.

So the fallback fails although its goal, no running container, is reached. The same kill failure appears 9 times in 180 days in CIDB (8 PRs and master).

The change retries the kill with the existing retry() helper, with the parameters of the docker compose up retries. Each attempt lists only the containers still running, and compose kill exits 0 when there are none (checked with compose 2.29.7 from the runner image and with v5.1.3). A persistent failure still raises after the third attempt.

Validation on test_s3_aws_sdk_has_slightly_unreliable_behaviour (same helper containers), with a throwaway docker wrapper injecting the CI outcome (stop fails, then kill kills everything and exits 1): without the change 1 passed, 1 error and the project leaks; with it 1 passed, the second kill prints No container to kill and the project is removed. A kill that always fails still errors after 3 attempts. Uninjected runs pass 3/3.


Workflow [PR]
Sync PR [sync-upstream/pr/123638]

Version info

  • Merged into: 26.10.1.1427-master (included in 26.10 and later)
  • Backported to: 26.9.34.22, 26.8.42.20

`ClickHouseCluster.shutdown()` runs `docker compose stop` and falls back
to `docker compose kill` when it fails. On a loaded runner dockerd can
give up on a container that needs more than its ~14 s kill budget to
exit after SIGKILL ("tried to kill container, but did not receive an
exit event"), so `stop` fails and aborts its walk. `compose kill` then
lists that container as still running, it exits a moment later, its kill
gets "container ... is not running" and `compose kill` exits 1 although
nothing is left running. The exception escapes `shutdown()`, so a module
whose tests all passed fails at teardown, and the log scans,
`down --volumes` and `cleanup()` are skipped, leaking the project.

Retry the fallback with the existing `retry()` helper and the same
parameters as the `docker compose up` retries. Each attempt lists only
the containers that are still running, and `compose kill` succeeds when
there is none (verified with compose 2.29.7 from the CI runner image and
v5.1.3). A persistent failure still raises after the last attempt.

Seen on PR ClickHouse#120632 in `test_hive_query` (hdfs1); the same kill-fallback
shape appears 9 times in 180 days in CIDB (8 PRs and master).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@groeneai groeneai added can be tested Allows running workflows for external contributors groeneai-origin-request PR origin: a maintainer pinged or directed groeneai labels Oct 3, 2026
@groeneai

groeneai commented Oct 3, 2026

Copy link
Copy Markdown
Collaborator Author
Internal second-model review: adjudication log (click to expand)

Pre-publication review by an independent model (engine: codex; 0 findings) plus my own cold review (2 nits).

# Sev Finding Verdict Evidence / action
1 💡 logging_compose_kill is a fourth nested retry log callback (cluster.py 3904, 3920, 4377) AGREE, noted Same local idiom as logging_compose_up; not extracted to keep the diff in shutdown()
2 💡 retry() also retries the 300 s run_and_check timeout, so a hung compose kill waits up to 3x before raising AGREE, noted Same shape as the docker compose up retries; only reachable with a wedged dockerd

Severity: ❌ blocker / ⚠️ major / 💡 nit. DISAGREE verdicts carry recorded evidence and are
terminal per finding.

Session id: cron:clickhouse-review-slot-9:20261003-002600

@groeneai

groeneai commented Oct 3, 2026

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? Yes for the harness side: a throwaway docker wrapper injects the CI outcome (stop exits 1, the first kill kills everything and exits 1); on master test_s3_aws_sdk_has_slightly_unreliable_behaviour gives 1 passed, 1 error at teardown, as in CI.
b Root cause explained? dockerd gave up on hdfs1 after ~14 s, so compose stop failed; the fallback compose kill got is not running for hdfs1 (exited ~0.1 s earlier) and exited 1 with nothing left running, and run_and_check raised it out of shutdown().
c Fix matches root cause? Yes: a retry re-lists only running containers and succeeds when none are left; real failures still raise.
d Test intent preserved / new tests added? No test changed; the CI-script change is validated with throwaway probes, as asked on #113200.
e Both directions demonstrated? Yes: without the change 1 passed, 1 error and the project leaks; with it 1 passed, the second kill prints No container to kill, down --volumes runs, nothing is left.
f Fix is general across code paths? shutdown()'s stop/kill fallback is the only teardown compose kill; down --volumes and cleanup() already tolerate failures.
g Fix generalizes across inputs (params/datatypes/wrappers)? compose 2.29.7 (runner image) and v5.1.3 both kill only running containers and exit 0 when none are; a persistent failure still errors after 3 attempts; green path 3/3.
h Backward compatible? (maintainer-approved exception only) Yes: only the teardown error path changes, with at most two extra pauses (3-5 s, then 4.5-6.5 s).
i Invariants and contracts preserved? shutdown() still raises when containers cannot be killed; the green path runs the same commands.

Session id: cron:clickhouse-impl-slot-7:20261003-000700

@clickhouse-gh

clickhouse-gh Bot commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [53fc0af]

Summary: ✅


AI Review

Summary

This PR narrows the ClickHouseCluster.shutdown() teardown failure mode that showed up in the referenced integration job: when docker compose stop fails because one helper container misses dockerd's exit-event window, the fallback docker compose kill is now retried with the same small backoff profile already used for flaky docker compose up operations. I reviewed the current tests/integration/helpers/cluster.py change, the PR discussion, and the referenced CI failure, and I did not find an actionable correctness, safety, or performance issue in the patch as written.

Final Verdict
  • Status: ✅ Approve

LLVM Coverage Report

Measured on commit 53fc0af.

Metric Baseline Current Δ
Lines 88.10% 88.10% +0.00%
Functions 91.70% 92.10% +0.40%
Branches 79.50% 79.50% +0.00%

Changed lines: Uncovered code analysis did not run: No coverable C/C++ source files changed (contrib/ is excluded from coverage).

Newly covered: +176 lines in 48 files (-109 lines lost coverage) · Details

Full report

@alexey-milovidov alexey-milovidov left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Amazing, thanks!

@alexey-milovidov alexey-milovidov self-assigned this Oct 3, 2026
@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Oct 3, 2026
Merged via the queue into ClickHouse:master with commit cd62a26 Oct 3, 2026
149 of 150 checks passed
@robot-ch-test-poll4 robot-ch-test-poll4 added the pr-synced-to-cloud The PR is synced to the cloud repo label Oct 3, 2026
@robot-ch-test-poll3 robot-ch-test-poll3 added the pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR label Nov 20, 2026
@robot-ch-test-poll robot-ch-test-poll added the pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore label Nov 20, 2026
clickhouse-gh Bot added a commit that referenced this pull request Nov 20, 2026
Backport #123638 to 26.9: Retry the forced kill in the integration cluster shutdown
clickhouse-gh Bot added a commit that referenced this pull request Nov 20, 2026
Backport #123638 to 26.8: Retry the forced kill in the integration cluster shutdown
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

can be tested Allows running workflows for external contributors comp-testing Test content only (no production code). groeneai-origin-request PR origin: a maintainer pinged or directed groeneai pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore pr-ci pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR pr-synced-to-cloud The PR is synced to the cloud repo v26.8-must-backport

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants