Skip to content

fix: stop a stale healthy marker from delaying restarted web and xhgui containers by 59s (#9019) [skip ci] - #9019

Merged
rfay merged 1 commit into
ddev:mainfrom
stasadev:20261027_stasadev_stale_healthy
Oct 28, 2026
Merged

rfay merged 1 commit into
ddev:mainfrom
stasadev:20261027_stasadev_stale_healthy

Conversation

@stasadev

Copy link
Copy Markdown
Member

Short Summary (TL;DR)

A web or xhgui container that Docker stopped and started again could take about 60 seconds to become healthy. Both images now remove the stale /tmp/healthy marker in PID 1, before the first healthcheck probe runs.

The Issue

@rpkoller reported Waiting for containers to become ready: [web db]... ready in 58.0s on macOS with Mutagen. The web log showed the same container running twice, with a stop in between. Quitting Docker or rebooting the host also stops containers without removing them.

The container's writable layer keeps /tmp/healthy from its last run. healthcheck.sh sleeps 59 seconds when it finds that file. Docker runs the first probe 1 second after the container starts.

  • web: /start.sh removes the marker, but ddev start runs /start.sh through docker exec only after the Mutagen sync. With a 1.9s Mutagen flush, the first probe finds the stale marker.
  • xhgui: nothing removes the marker, so ddev xhgui on waits 59 seconds after a stop.

The db, router, and ssh-agent entrypoints already remove the marker as PID 1.

How This PR Solves The Issue

  • web: pre-start.sh, which is PID 1, removes /tmp/healthy first. /start.sh keeps its own rm for a ddev start on a container that is already up.
  • xhgui: a CMD removes /tmp/healthy, then starts nginx and php-fpm with the command from xhgui/xhgui:0.23.

Manual Testing Instructions

ddev utility download-ddev --pr 9019
export PATH="$HOME/tmp/ddev-download-ddev/pr-9019:$PATH"
mkdir ~/tmp/healthyrepro && cd ~/tmp/healthyrepro
ddev config --project-type=php --performance-mode=mutagen
ddev start -y
docker stop ddev-healthyrepro-web
# A slower Mutagen flush makes the race reproduce on fast hosts
mkdir bulk && (cd bulk && seq 1 30000 | xargs touch)
ddev start -y
# Expect "ready in" a few seconds; v1.25.5 shows about 56s here
ddev xhgui on
docker stop ddev-healthyrepro-xhgui
ddev xhgui on
# Expect the xhgui wait to take a few seconds, not about 60s

🤖 Developed with assistance from Claude Code

@stasadev
stasadev requested a review from a team as a code owner October 27, 2026 13:01
@github-actions github-actions Bot added bugfix dependencies Pull requests that update a dependency file labels Oct 27, 2026
@github-actions

github-actions Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

Download this PR's build for your OS and architecture with:

ddev utility download-ddev --pr 9019

Or download the artifact for your OS and architecture directly:

See Testing a PR.

Open in GitHub Codespaces

@github-actions

Copy link
Copy Markdown

Pushed updated container image(s) for this PR:

  • ddev/ddev-webserver-prod:fdeab11b99
  • ddev/ddev-webserver:fdeab11b99
  • ddev/ddev-xhgui:800862dd86

@rfay rfay 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.

Looks like a good idea to me. I wonder if there's a way to generalize this even more.

Also, the fact that Docker has not (yet) provided a way to back off the healthchecks after healthy even though it would have made sense is worth looking into again, in case they've done something to make this obsolete.

This complexity was originally added because of complaints about battery life on laptops, and it's mostly worked out OK, but this is a great case where it doesn't necessarily.

@stasadev

Copy link
Copy Markdown
Member Author

I wonder if there's a way to generalize this even more

I agree, and would like to have something simpler, but not here.

…i containers by 59s

## Short Summary (TL;DR)

A web or xhgui container that Docker stopped and started again could take about 60 seconds to become healthy. Both images now remove the stale `/tmp/healthy` marker in PID 1, before the first healthcheck probe runs.

## The Issue

@rpkoller reported `Waiting for containers to become ready: [web db]... ready in 58.0s` on macOS with Mutagen. The web log showed the same container running twice, with a stop in between. Quitting Docker or rebooting the host also stops containers without removing them.

The container's writable layer keeps `/tmp/healthy` from its last run. `healthcheck.sh` sleeps 59 seconds when it finds that file. Docker runs the first probe 1 second after the container starts.

- web: `/start.sh` removes the marker, but `ddev start` runs `/start.sh` through `docker exec` only after the Mutagen sync. With a 1.9s Mutagen flush, the first probe finds the stale marker.
- xhgui: nothing removes the marker, so `ddev xhgui on` waits 59 seconds after a stop.

The db, router, and ssh-agent entrypoints already remove the marker as PID 1.

## How This PR Solves The Issue

- web: `pre-start.sh`, which is PID 1, removes `/tmp/healthy` first. `/start.sh` keeps its own `rm` for a `ddev start` on a container that is already up.
- xhgui: a `CMD` removes `/tmp/healthy`, then starts nginx and php-fpm with the command from `xhgui/xhgui:0.23`.

## Manual Testing Instructions

```bash
ddev utility download-ddev --pr 9019
export PATH="$HOME/tmp/ddev-download-ddev/pr-9019:$PATH"
mkdir ~/tmp/healthyrepro && cd ~/tmp/healthyrepro
ddev config --project-type=php --performance-mode=mutagen
ddev start -y
docker stop ddev-healthyrepro-web
# A slower Mutagen flush makes the race reproduce on fast hosts
mkdir bulk && (cd bulk && seq 1 30000 | xargs touch)
ddev start -y
# Expect "ready in" a few seconds; v1.25.5 shows about 56s here
ddev xhgui on
docker stop ddev-healthyrepro-xhgui
ddev xhgui on
# Expect the xhgui wait to take a few seconds, not about 60s
```

🤖 Developed with assistance from [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@stasadev
stasadev force-pushed the 20261027_stasadev_stale_healthy branch from 68ffd41 to cd11299 Compare October 27, 2026 16:18
@rpkoller

Copy link
Copy Markdown
Collaborator

lol i've first tested with the artifact and wondered why nothing happened. but then realized that the artifact provides the fixes and i also have to test with HEAD in comparison. in doing so i can confirm, with HEAD the web container took 575 seconds to start up and xhgui 60 seconds exactly. so the PR is fixing the problem. thank you!

@rfay rfay changed the title fix: stop a stale healthy marker from delaying restarted web and xhgui containers by 59s fix: stop a stale healthy marker from delaying restarted web and xhgui containers by 59s (#9019) [skip ci] Oct 28, 2026
@rfay
rfay merged commit ad44cf6 into ddev:main Oct 28, 2026
55 of 56 checks passed
@rfay
rfay deleted the 20261027_stasadev_stale_healthy branch October 28, 2026 17:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugfix dependencies Pull requests that update a dependency file

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants