Skip to content

Improving SQL container Health Checks for Env #70973

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: trunk
Choose a base branch
from

Conversation

SirLouen
Copy link
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.

Copy link

github-actions bot commented Jul 30, 2025

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 <[email protected]>
Co-authored-by: desrosj <[email protected]>

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
Copy link
Member

@desrosj desrosj left a comment

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
Member Author

Closing this in favour to #70987

@desrosj
Copy link
Member

desrosj commented Jul 31, 2025

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

'--connect',
'--innodb_initialized',
],
timeout: '20s',
Copy link
Member

Choose a reason for hiding this comment

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

I think this could be a bit lower. If retries is set to 10, how about 5s or 10s?

@@ -186,6 +186,16 @@ module.exports = function buildDockerComposeConfig( config ) {
mysql: {
image: 'mariadb:lts',
ports: [ developmentMysqlPorts ],
healthcheck: {
Copy link
Member

Choose a reason for hiding this comment

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

Since the healthcheck is the same for both mysql and test-mysql, would it make sense to define a const above that's used in both places so that there's no duplication?

@desrosj desrosj requested a review from Mamaduka July 31, 2025 03:04
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.

2 participants