Skip to content

tests: attempt to fix hangs of postgres container (leads to tests timeouts) - #79360

Merged
azat merged 1 commit into
ClickHouse:masterfrom
azat:tests/postgres
Apr 22, 2025
Merged

azat merged 1 commit into
ClickHouse:masterfrom
azat:tests/postgres

Conversation

@azat

@azat azat commented Apr 20, 2025

Copy link
Copy Markdown
Member

Sometimes after pause/unpause postgres does not respond the healthcheck 1:

time="2025-04-19T21:55:59.978956920Z" level=debug msg="Calling POST /v1.46/containers/fc4c98917ee891cd27564cab1c248c66e443f1fc2e3f026b7de84762bc10e924/pause"
time="2025-04-19T21:55:59.984831645Z" level=debug msg="CloseMonitorChannel: waiting for probe to stop"
time="2025-04-19T21:55:59.984852523Z" level=debug msg="CloseMonitorChannel done"
time="2025-04-19T21:55:59.984890483Z" level=debug msg=event module=libcontainerd namespace=moby topic=/tasks/paused
time="2025-04-19T21:55:59.984910613Z" level=debug msg="Stop healthcheck monitoring for container fc4c98917ee891cd27564cab1c248c66e443f1fc2e3f026b7de84762bc10e924 (received while probing)"
time="2025-04-19T21:55:59.985084214Z" level=error msg="stream copy error: reading from a closed fifo"
time="2025-04-19T21:55:59.985264774Z" level=debug msg="Calling GET /v1.46/containers/fc4c98917ee891cd27564cab1c248c66e443f1fc2e3f026b7de84762bc10e924/json"
time="2025-04-19T21:55:59.985291238Z" level=error msg="stream copy error: reading from a closed fifo"
time="2025-04-19T21:55:59.985433994Z" level=debug msg="attach: stdout: end"
time="2025-04-19T21:55:59.985495990Z" level=debug msg="attach: stderr: end"
time="2025-04-19T21:55:59.985506632Z" level=debug msg="attach done"
time="2025-04-19T21:56:00.039673414Z" level=debug msg="Calling HEAD /_ping"
time="2025-04-19T21:56:00.040310748Z" level=debug msg="Calling GET /v1.46/info"
time="2025-04-19T21:56:00.054755490Z" level=debug msg="Calling GET /v1.46/containers/json?filters=%7B%22label%22%3A%7B%22com.docker.compose.config-hash%22%3Atrue%2C%22com.docker.compose.oneoff%3DFalse%22%3Atrue%2C%22com.docker.compose.project%3Droottestpostgresqlreplicadatabaseengine1-gw0%22%3Atrue%2C%22com.docker.compose.service%3Dpostgres1%22%3Atrue%7D%7D"
time="2025-04-19T21:56:00.055847976Z" level=debug msg="Calling POST /v1.46/containers/fc4c98917ee891cd27564cab1c248c66e443f1fc2e3f026b7de84762bc10e924/unpause"
time="2025-04-19T21:56:29.976612151Z" level=warning msg="Health check for container fc4c98917ee891cd27564cab1c248c66e443f1fc2e3f026b7de84762bc10e924 error: timed out starting health check for container fc4c98917ee891cd27564cab1c248c66e443f1fc2e3f026b7de84762bc10e924"

There the DROP DATABASE hanged, likely due to postgres does not respond.

Let's try autoheal

Changelog category (leave one):

  • Not for changelog (changelog entry is not required)

…eouts)

Sometimes after pause/unpause postgres does not respond the healthcheck [1]:

    time="2025-04-19T21:55:59.978956920Z" level=debug msg="Calling POST /v1.46/containers/fc4c98917ee891cd27564cab1c248c66e443f1fc2e3f026b7de84762bc10e924/pause"
    time="2025-04-19T21:55:59.984831645Z" level=debug msg="CloseMonitorChannel: waiting for probe to stop"
    time="2025-04-19T21:55:59.984852523Z" level=debug msg="CloseMonitorChannel done"
    time="2025-04-19T21:55:59.984890483Z" level=debug msg=event module=libcontainerd namespace=moby topic=/tasks/paused
    time="2025-04-19T21:55:59.984910613Z" level=debug msg="Stop healthcheck monitoring for container fc4c98917ee891cd27564cab1c248c66e443f1fc2e3f026b7de84762bc10e924 (received while probing)"
    time="2025-04-19T21:55:59.985084214Z" level=error msg="stream copy error: reading from a closed fifo"
    time="2025-04-19T21:55:59.985264774Z" level=debug msg="Calling GET /v1.46/containers/fc4c98917ee891cd27564cab1c248c66e443f1fc2e3f026b7de84762bc10e924/json"
    time="2025-04-19T21:55:59.985291238Z" level=error msg="stream copy error: reading from a closed fifo"
    time="2025-04-19T21:55:59.985433994Z" level=debug msg="attach: stdout: end"
    time="2025-04-19T21:55:59.985495990Z" level=debug msg="attach: stderr: end"
    time="2025-04-19T21:55:59.985506632Z" level=debug msg="attach done"
    time="2025-04-19T21:56:00.039673414Z" level=debug msg="Calling HEAD /_ping"
    time="2025-04-19T21:56:00.040310748Z" level=debug msg="Calling GET /v1.46/info"
    time="2025-04-19T21:56:00.054755490Z" level=debug msg="Calling GET /v1.46/containers/json?filters=%7B%22label%22%3A%7B%22com.docker.compose.config-hash%22%3Atrue%2C%22com.docker.compose.oneoff%3DFalse%22%3Atrue%2C%22com.docker.compose.project%3Droottestpostgresqlreplicadatabaseengine1-gw0%22%3Atrue%2C%22com.docker.compose.service%3Dpostgres1%22%3Atrue%7D%7D"
    time="2025-04-19T21:56:00.055847976Z" level=debug msg="Calling POST /v1.46/containers/fc4c98917ee891cd27564cab1c248c66e443f1fc2e3f026b7de84762bc10e924/unpause"
    time="2025-04-19T21:56:29.976612151Z" level=warning msg="Health check for container fc4c98917ee891cd27564cab1c248c66e443f1fc2e3f026b7de84762bc10e924 error: timed out starting health check for container fc4c98917ee891cd27564cab1c248c66e443f1fc2e3f026b7de84762bc10e924"

  [1]: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=79349&sha=4a2ce10124c6cdc507305822d28248c49c71df47&name_0=PR&name_1=Integration%20tests%20%28asan%2C%20old%20analyzer%2C%203%2F6%29

There the DROP DATABASE hanged, likely due to postgres does not respond.

Let's try autoheal
@azat azat added the 🍃 green ci 🌿 Fixing flaky tests in CI label Apr 20, 2025
@clickhouse-gh

clickhouse-gh Bot commented Apr 20, 2025 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [4109149]

@clickhouse-gh clickhouse-gh Bot added the pr-not-for-changelog This PR should not be mentioned in the changelog label Apr 20, 2025
@azat

azat commented Apr 22, 2025

Copy link
Copy Markdown
Member Author

Let's give it a try

@azat
azat added this pull request to the merge queue Apr 22, 2025
Merged via the queue into ClickHouse:master with commit 8b52f63 Apr 22, 2025
@azat
azat deleted the tests/postgres branch April 22, 2025 10:49
@robot-clickhouse robot-clickhouse added the pr-synced-to-cloud The PR is synced to the cloud repo label Apr 22, 2025
groeneai added a commit to groeneai/ClickHouse that referenced this pull request Nov 23, 2026
…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]>
subkanthi pushed a commit to subkanthi/ClickHouse that referenced this pull request Nov 23, 2026
…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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🍃 green ci 🌿 Fixing flaky tests in CI pr-not-for-changelog This PR should not be mentioned in the changelog 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.

2 participants