Skip to content

Improving SQL container Health Checks for Env - #70973

Closed
SirLouen wants to merge 2 commits into
WordPress:trunkfrom
SirLouen:fix/env-mysql-healthcheck
Closed

SirLouen wants to merge 2 commits into
WordPress:trunkfrom
SirLouen:fix/env-mysql-healthcheck

Conversation

@SirLouen

Copy link
Copy Markdown
Member

What?

It appears that there have been several errors when running Docker containers for CI, as reported here like
https://github.com/WordPress/gutenberg/actions/runs/16615410203/job/47007147722?pr=70970

As @talldan has commented, maybe better logging could be implemented to see where is the issue.

Why?

One of the issues I've personally encountered with docker configurations with the WP images is the fact that mariadb takes a variable amount of time to load, and it can load a little later than the PHP server under certain conditions.

How?

To ensure that the DB is loading 100% before the PHP container, a healthcheck could do the trick

I'm taking Official docs for implementing a valid healtcheck for the maridb docker images:
https://mariadb.com/docs/server/server-management/install-and-upgrade-mariadb/installing-mariadb/binary-packages/automated-mariadb-deployment-and-administration/docker-and-mariadb/using-healthcheck-sh

Testing Instructions

  1. Just run npx wp-env start

I want to see how well this patch goes with current GHA.

@github-actions

github-actions Bot commented Jul 30, 2025 •

Copy link
Copy Markdown

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: SirLouen <sirlouen@git.wordpress.org>
Co-authored-by: desrosj <desrosj@git.wordpress.org>
Co-authored-by: Mamaduka <mamaduka@git.wordpress.org>
Co-authored-by: t-hamano <wildworks@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@SirLouen SirLouen added the [Tool] Env /packages/env label Jul 30, 2025
@SirLouen SirLouen assigned SirLouen and unassigned SirLouen Jul 30, 2025
@SirLouen SirLouen added the [Type] Build Tooling Issues or PRs related to build tooling label Jul 30, 2025

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

I missed this before creating my PR, but I've created #70987 as an alternative approach.

The healthcheck.sh script may not exist reliably within the containers for older versions of MariaDB. It seems like this was added in 10.4.30 and newer. Technically we still support back through 5.5.

We could adjust the conditional in #70987 to use healthcheck.sh as the fallback instead of mariadb-admin ping -h localhost, but solely relying on it will likely result in failures when using old versions.

@SirLouen

Copy link
Copy Markdown
Member Author

Closing this in favour to #70987

@desrosj

desrosj commented Jul 31, 2025

Copy link
Copy Markdown
Member

Since the version of mariadb can't be changed like in WordPress/wordpress-develop, let's go with this simpler approach.

@desrosj
desrosj requested a review from Mamaduka July 31, 2025 03:04
@Mamaduka

Copy link
Copy Markdown
Member

I can confirm that npm run wp-env start works as before on this branch. But I noticed that it's relatively slow, compared to trunk, while the stop command remains the same. 36s vs 5s.

Before After
CleanShot 2025-08-11 at 18 47 58 CleanShot 2025-08-11 at 18 46 59

@t-hamano

Copy link
Copy Markdown
Contributor

Today I was able to get CI to fail for the first time with a PR that added debug code. I hope this log helps.

https://github.com/WordPress/gutenberg/actions/runs/17906582725/job/50909053610?pr=70979

The core of the failure is probably this:

target wordpress: failed to solve: process "/bin/sh -c apt-get -qy install sudo" did not complete successfully: exit code: 100

@SirLouen
SirLouen force-pushed the fix/env-mysql-healthcheck branch from e4eb3d6 to a44d0ae Compare November 29, 2025 01:05
@SirLouen
SirLouen requested a review from desrosj November 29, 2025 01:05
@SirLouen

Copy link
Copy Markdown
Member Author

I was reviewing my old tickets and found this one that has become a little stale.

@t-hamano @Mamaduka we have not located this issue again?
Anyway this is a good improvement as we are not currently health checking MySQL status before running the instance, generally speaking, it's a good practice to do so regardless whether we are encountering error or not.

@SirLouen SirLouen self-assigned this Nov 29, 2025
@SirLouen SirLouen removed their assignment Feb 6, 2026
@Mamaduka

Mamaduka commented Nov 4, 2026

Copy link
Copy Markdown
Member

This was resolved via #83751.

@Mamaduka Mamaduka closed this Nov 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Tool] Env /packages/env [Type] Build Tooling Issues or PRs related to build tooling

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants