WordPress / gutenberg

The Block Editor project for WordPress and beyond. Plugin is available from the official repository.
https://wordpress.org/gutenberg/
Other
10.34k stars 4.13k forks source link

wp-env Error while running docker compose command #62242

Open louiswol94 opened 3 months ago

louiswol94 commented 3 months ago

Description

Hi there,

We are experiencing the following issue with wp-env:

Error while running docker compose command. Container 389b8d981d610881ee022d53ce63130e-tests-mysql-1 Running Container 389b8d981d610881ee022d53ce63130e-tests-wordpress-1 Running Error: Error establishing a database connection. This either means that the username and password information in your wp-config.php file is incorrect or that contact with the database server at tests-mysql could not be established. This could mean your host’s database server is down.

It is happening in more than one of our repositories at the moment.

I see a MariaDB version was released a few days ago. Maybe it is related: https://mariadb.org/mariadb/all-releases/

Step-by-step reproduction instructions

  1. run wp-env start

Screenshots, screen recording, code snippet

No response

Environment info

Please confirm that you have searched existing issues in the repo.

Yes

Please confirm that you have tested with all plugins deactivated except Gutenberg.

Yes

paolopiaggio commented 3 months ago

+1

louiswol94 commented 3 months ago

If anyone needs a temporary workaround, I updated the mariadb:lts to mariadb:11.2.4-jammy in my node_modules/@wordpress/env/lib/build-docker-compose-config.js

If you are running this on a CI script you can run sed -i -e "s/image: 'mariadb:lts'/image: 'mariadb:11.2.4-jammy'/g" node_modules/@wordpress/env/lib/build-docker-compose-config.js right after npm ci for example.

It works for now, until there is a fix from wp-env or MariaDB's side.

talldan commented 1 month ago

This is something I've seen too, but it's very intermittent for me. I've only seen it once in my local environment, but it's the cause of a lot of test failures in this repo's CI. There's an example here - https://github.com/WordPress/gutenberg/actions/runs/10087381455/job/27891446096?pr=63918.

It'd be good if there was more error logging to know what the actual mariadb error is, that way it could be reported upstream.

If anyone needs a temporary workaround, I updated the mariadb:lts to mariadb:11.2.4-jammy in my node_modules/@wordpress/env/lib/build-docker-compose-config.js

That seems like a downgrade rather than an update, as LTS is 11.4.

peterfabian commented 1 month ago

Seems also related to https://github.com/WordPress/gutenberg/issues/59244 where the switch to the lts version happened. It's quite annoying, so +1 on adding more logging, and potentially some retries/waiting for MySQL service to help with CI stability. We've been encountering this almost every other day.

talldan commented 1 month ago

Good spot, it does seem like a similar issue, though now only intermittent.

It does look like mariadb recently made 11.4 LTS (https://mariadb.org/11-4-lts/), and that seems to correlate with when the flakiness started. 🤔

In terms of better logging, I wonder if we can add the log files to the github action job artifacts when failing at the 'Install WordPress' stage.