Build: Add retry logic to env:install for database connection race condition #10834
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR adds retry logic with exponential backoff to the
wp config createcommand intools/local-env/scripts/install.jsto handle intermittent database connection failures during environment setup.The Problem
The
env:installscript fails intermittently with "Database connection error (2002) Connection refused" because:mysqladmin ping) passes when the database process is runningwp config createcommand runs immediately without any waitThis causes random CI job failures across different PHP/MariaDB combinations.
Approach Chosen: Application-Level Retry
This PR adds a
wp_cli_with_retry()function that retries theconfig createcommand with exponential backoff (1s, 2s, 4s, 8s, 16s).Pros:
docker-compose.ymlCons:
install.jsAlternative Considered: Improved Docker Healthcheck
Change the healthcheck in
docker-compose.ymlfrom ping-based to connection-based:Pros:
Cons:
Trac ticket: https://core.trac.wordpress.org/ticket/64579
This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.