Skip to content

Keep the autoheal sidecar from restarting a postgres1 that La Casa Del Dolor paused - #133501

Merged
PedroTadim merged 3 commits into
ClickHouse:masterfrom
groeneai:casa-del-dolor-hold-autoheal-during-postgres-pause
Nov 23, 2026
Merged

PedroTadim merged 3 commits into
ClickHouse:masterfrom
groeneai:casa-del-dolor-hold-autoheal-during-postgres-pause

Conversation

@groeneai

@groeneai groeneai commented Nov 22, 2026 •

Copy link
Copy Markdown
Collaborator

Related: #131994

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

Failure. La Casa Del Dolor (amd_debug) fails with dolor.py exception: docker compose ... unpause postgres1 returns Error response from daemon: Container ... is not paused. Seen on two unrelated PRs: #121944, #129649.

Root cause. Docker reports a paused container with a healthcheck as unhealthy. docker_compose_postgres.yml runs the autoheal sidecar, which restarts unhealthy postgres1 every 5 s once its 600 s start period (#79360) is over. La Casa runs 15 minutes and, since #131994, pauses integrations, so a postgres pause after minute 10 gets restarted. The restart resumes the container and the unpause fails. Both runs' dockerd logs show pause, the sidecar's health=unhealthy query, restart, then the failed unpause.

Change. After the cluster starts, when PostgreSQL is enabled, dolor stops the sidecar for the rest of the run, so a paused postgres1 stays paused until dolor unpauses it. La Casa does not need the sidecar: postgres1 has restart: always, and dolor stops, kills and starts it at random, so a hung postgres1 is restarted by the next restart dolor picks. On sanitizer runs dolor restarts no integration, and the sidecar could only act after minute 10. The integration tests keep it. No other compose file has an autoheal sidecar.

Validation. A temporary integration test on the real docker_compose_postgres.yml, past the sidecar's 600 s start period: with the sidecar running, pausing and unpausing postgres1 raised the CI exception. With the line from dolor.py run after cluster.start(), the sidecar stayed exited (RestartCount 0) through 4 pause/unpause, 1 stop/start and 1 kill/start of postgres1; every unpause succeeded, no pause restarted it, and SELECT 1 worked after each.

Alternative: revert the pause/unpause lines #131994 added to dolor.py.

🤖 Generated with Claude Code


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

Version info

  • Merged into: 26.12.1.279-master (included in 26.12 and later)

…l Dolor paused

La Casa Del Dolor (amd_debug) failed with `dolor.py exception` on unrelated PRs:
`docker compose ... unpause postgres1` returned "Container ... is not paused".

Docker reports a paused container that has a healthcheck as unhealthy (pausing
closes its health monitor) and keeps that status after the unpause until the
next probe, which runs only after `interval` (10 s for postgres1). The postgres
compose file labels postgres1 `autoheal=true` and runs the
willfarrell/autoheal sidecar, which restarts every labelled unhealthy
container every 5 s after a 600 s start period (ClickHouse#79360). La Casa runs 15
minutes and pauses integrations since ClickHouse#131994, so a postgres pause after
minute 10 is restarted by the sidecar: the restart resumes the container and
the unpause fails. The dockerd debug logs of both failing runs show pause,
the sidecar's `health=unhealthy` query, `restart?t=10`, then the failed
unpause.

When dolor pauses postgres1 it now pauses the sidecar first, and resumes it
once postgres1 is healthy again. Resuming it right after the unpause is not
enough, because the status is still unhealthy until the first probe. The wait
is bounded at 60 s, after which the sidecar is resumed anyway, so a postgres
that stays unresponsive after a pause is still healed (the reason ClickHouse#79360 added
the sidecar).

Not chosen: pausing with SIGSTOP (`docker kill --signal`) freezes only the
postmaster, so established connections keep answering and clients see no
hang, which defeats the purpose of the pause; stopping the sidecar for the
whole run drops the recovery; making `unpause` tolerate a running container
would hide that the pause turned into an unscheduled restart.

Validated locally (no committed test: fuzzer harness change): with the
current sequence `unpause` fails 5/5; with the new one 5/5 runs have no
restart and no error, and postgres is healthy about 10 s after the unpause.
A temporary integration test on the real compose file reproduced the CI
exception after the 600 s start period and ran the new sequence 3/3 cleanly.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@groeneai

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 (1 nit).

# Sev Finding Verdict Evidence / action
1 💡 POSTGRES_HEALTHY_TIMEOUT is defined in dolor.py, while the other timing constants live in properties.py with a _SECONDS suffix AGREE, not changed noted, not blocking

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

Session id: cron:clickhouse-review-slot-9:20261122-070400

@groeneai

Copy link
Copy Markdown
Collaborator Author

cc @PedroTadim, could you review this? La Casa Del Dolor pauses postgres1 since #131994, and the autoheal sidecar of docker_compose_postgres.yml restarts it because Docker reports a paused container as unhealthy, so the unpause fails with 'is not paused'; dolor now pauses the sidecar during a postgres pause and resumes it once postgres1 is healthy again (at most 60 s).

@groeneai

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? Yes. A postgres container with the same healthcheck plus willfarrell/autoheal:1.2.0 (start period 0): pause 6 s, then unpause fails with is not paused in 5/5. A temporary integration test on the real docker_compose_postgres.yml, after the 600 s start period, raised the CI exception 1/1.
b Root cause explained? Docker marks a paused container with a healthcheck unhealthy until the first probe after the unpause. The autoheal sidecar restarts unhealthy postgres1 once its 600 s start period is over, the restart resumes the container, and dolor's unpause fails. The dockerd logs of both CI runs show this sequence.
c Fix matches root cause? Yes. The sidecar is paused for exactly the window in which the health status is wrong: from before the pause until postgres1 is healthy again, at most 60 s. unpause is not made tolerant, and a pause stays a pause.
d Test intent preserved / new tests added? No committed test: this is a change to the fuzzer harness, so per the ruling on test-infrastructure changes (#119766) it is validated locally (rows a and e).
e Both directions demonstrated? Yes. Same container setup: the current sequence fails 5/5, the new one is clean 5/5 (no restart, healthy about 10 s after the unpause). Same integration cluster: the control raised, the new sequence passed 3/3, with SELECT 1 working after each run.
f Fix is general across code paths? The postgres compose file is the only one with autoheal, so none of the other services La Casa pauses has anything acting on its health. kill and stop of postgres are unaffected and not held.
g Fix generalizes across inputs (params/datatypes/wrappers)? Pause lengths of 1 s and 6 s were checked (dolor uses 3-5 s). A postgres that stays unhealthy (postmaster SIGSTOPped) is healed by the sidecar once the 60 s bound passes (1/1).
h Backward compatible? (maintainer-approved exception only) Yes. Harness only: no settings, no compose change, and integration tests are untouched.
i Invariants and contracts preserved? A dolor pause is always followed by a successful unpause. The autoheal recovery from #79360 stays active for the whole run, held for at most 60 s after an unpause. Every compose action still goes through process_integration_nodes.

Session id: cron:clickhouse-impl-slot-4:20261122-063300

@clickhouse-gh

clickhouse-gh Bot commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [fa28476]

Summary: ✅


AI Review

Summary

The PR stops autoheal during La Casa Del Dolor's PostgreSQL setup so intentional pauses of postgres1 remain intact until the harness unpauses it. Reviewed head fa28476c4e7e84a0c63a815d86a379b8000a6edc, the current diff, all prior discussion, and the affected startup, restart, and cleanup paths. The previous finding concerned the removed sidecar pause/resume implementation and is resolved. No new actionable findings. The reported Docker validation covers pause/unpause, stop/start, and kill/start after the sidecar's start period; tests were not rerun locally.

Final Verdict

Status: ✅ Approve

@clickhouse-gh clickhouse-gh Bot added pr-ci can be tested Allows running workflows for external contributors manual approve Manual approve required to run CI comp-testing Test content only (no production code). labels Nov 22, 2026
Comment thread tests/casa_del_dolor/dolor.py Resolved
Review of ClickHouse#133501: pausing the sidecar keeps its in-flight requests. A
`GET /containers/json` it sent just before the pause can be answered by
the daemon after postgres1 is paused, so the answer lists postgres1 as
unhealthy, and the resumed sidecar restarts it from that list without
checking again (autoheal 1.2.0 entrypoint), even though postgres1 is
healthy by then.

dolor now pauses the sidecar, checks that no `curl` runs in it, and if
one does, unpauses it, waits 0.2 s and tries again, for at most 40 s
(above the sidecar's CURL_TIMEOUT of 30 s). With no request in flight
when postgres1 is paused, the first request after the resume is a fresh
query of a healthy postgres1. If a request is still in flight after
40 s, postgres1 is restarted with stop/start instead of the pause: the
sidecar lists only running containers, so it cannot restart a stopped
one.

The check reads the frozen process tree from /proc, not `docker top`:
the autoheal image has its own healthcheck (every 5 s), its exec stalls
in the paused container, and `docker top` waits behind it in the
containerd shim. Measured: one `top` call blocked past the 60 s client
timeout. dolor runs next to the docker-in-docker daemon it drives, so
the container's `State.Pid` is valid in its /proc.

Validated with a unix socket proxy between the sidecar and dockerd that
holds the sidecar's list request until postgres1 is paused (the
ordering from the review), on Docker 29.5.1 and on dockerd 27.0.3 in
the integration runner image: the previous sequence restarted the
healthy postgres1 3/3, this one 0/3. Ordinary pauses 5/5 without a
restart; 300 drains against a sidecar polling without a sleep returned
paused with no `curl` every time (39-61 retried, slowest 2.1 s); a
request held past 40 s takes the stop/start path with no sidecar
restart; a postgres that stays unresponsive after the pause is still
healed. On the real docker_compose_postgres.yml after the 600 s start
period, master's sequence raised the CI exception and the new restart
block ran 3/3 without a restart.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@PedroTadim PedroTadim self-assigned this Nov 23, 2026
@PedroTadim

Copy link
Copy Markdown
Member

🕵️ @groeneai The analysis is right and the code works, but this is a lot of machinery to keep a sidecar La Casa does not need. postgres1 has restart: always, and dolor stops and starts it at random, so a postgres1 that hangs gets restarted by the next restart dolor picks. autoheal exists for the pause false positives of the integration tests (see the comment in docker_compose_postgres.yml). Could dolor instead stop the sidecar once after the cluster starts, when postgres is enabled?

# The sidecar restarts a paused postgres1, which Docker reports as unhealthy, so dolor's unpause fails
cluster.process_integration_nodes("postgres", ["autoheal"], "stop")

That keeps the pause a pause and drops the /proc walk, the drain loop and the health wait.

…tgres pause

Review of ClickHouse#133501 (@ PedroTadim): La Casa Del Dolor does not need the sidecar.
`postgres1` has `restart: always`, and dolor stops, kills and starts it at
random, so a `postgres1` that hangs is restarted by the next restart dolor
picks. The sidecar only exists for the pause false positives of the
integration tests (ClickHouse#79360). So dolor now stops it once after the cluster
starts, when PostgreSQL is enabled, and drops the /proc walk, the drain loop
and the health wait of the two previous commits.

A stopped `restart: always` container stays stopped: Docker restarts it only
on a daemon restart or an explicit start, and `docker compose start postgres1`
starts only `postgres1`.

Validated with a temporary integration test on the real
docker_compose_postgres.yml, past the sidecar's 600 s start period: the
control (sidecar left running) raised the CI exception `unpause postgres1 ...
is not paused`, and with this line executed from dolor.py the sidecar stayed
exited (RestartCount 0) through pause/unpause, stop/start and kill/start of
`postgres1`, every unpause succeeded and `postgres1` was not restarted.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@groeneai

Copy link
Copy Markdown
Collaborator Author

Done in fa28476: dolor stops the sidecar once after the cluster starts when PostgreSQL is enabled (your line), and the drain loop, the /proc walk and the health wait are gone, so the PR diff is now these 2 lines. On the real compose file, past the sidecar's 600 s start period, the stopped sidecar stayed stopped (RestartCount 0, restart: always does not bring it back) through pause/unpause, stop/start and kill/start of postgres1, and every unpause succeeded; with the sidecar running, the same pause hit is not paused. I updated the description.

@PedroTadim
PedroTadim enabled auto-merge November 23, 2026 14:10
@PedroTadim
PedroTadim added this pull request to the merge queue Nov 23, 2026
Merged via the queue into ClickHouse:master with commit 75d0e55 Nov 23, 2026
194 checks passed
@robot-ch-test-poll3 robot-ch-test-poll3 added the pr-synced-to-cloud The PR is synced to the cloud repo label Nov 23, 2026
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). manual approve Manual approve required to run CI pr-ci pr-synced-to-cloud The PR is synced to the cloud repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants