Skip to content

Conversation

@peterwilsoncc
Copy link
Contributor

@peterwilsoncc peterwilsoncc commented Jul 28, 2025

This is an attempt to recover if the database server hasn't completed booting when the web server starts.

If the wp db reset command fails, it will be retried a number of times to ensure that the error is permanent rather than temporary.

On the test suite, I've been seeing a lot of failures that are seemingly caused by a race condition rather than an error when docker is started. As a case in point, see this action run.

I've not seen any such errors with this code but that may be dumb luck rather than anything I've fixed.

Trac ticket: https://core.trac.wordpress.org/ticket/63167


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.

@github-actions
Copy link

Test using WordPress Playground

The changes in this pull request can previewed and tested using a WordPress Playground instance.

WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser.

Some things to be aware of

  • The Plugin and Theme Directories cannot be accessed within Playground.
  • All changes will be lost when closing a tab with a Playground instance.
  • All changes will be lost when refreshing the page.
  • A fresh instance is created each time the link below is clicked.
  • Every time this pull request is updated, a new ZIP file containing all changes is created. If changes are not reflected in the Playground instance,
    it's possible that the most recent build failed, or has not completed. Check the list of workflow runs to be sure.

For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation.

Test this pull request with WordPress Playground.

@peterwilsoncc peterwilsoncc changed the title waiton mysql server when starting environment. Retry database reset a few times to allow time for it to come online. Jul 28, 2025
@peterwilsoncc peterwilsoncc marked this pull request as ready for review July 28, 2025 05:51
@github-actions
Copy link

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.

Core Committers: Use this line as a base for the props when committing in SVN:

Props peterwilsoncc.

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

Copy link
Member

@johnbillion johnbillion left a comment

Choose a reason for hiding this comment

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

I got thoroughly fed up of these database connection errors in the test suites for my plugins so I ended up with a comprehensive wait mechanism: https://github.com/johnbillion/plugin-infrastructure/blob/313e0b6ef3da09aefec813d6f6c619a2f0af40c9/bin/acceptance-tests#L30-L38 . If we could translate that into node it would be a solid solution.

if ( retries > 0 ) {
console.warn( `Retrying command "${cmd}" (${retries} retries left)...` );
// Wait a bit before retrying.
setTimeout( () => {}, 1000 );
Copy link
Member

Choose a reason for hiding this comment

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

setTimeout() delays the execution of its callback, not the code that follows it, so this doesn't delay anything.

@peterwilsoncc
Copy link
Contributor Author

Thanks for taking a look John.

I've realized this is the wrong approach. The docker file already has a depends_on config so I suspect it's something else funky going on.

@peterwilsoncc peterwilsoncc deleted the waiton-mysql-server branch July 28, 2025 22:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants