Change mysqladmin ping timeout

I have a large mysql database that has been imported into a Local site. The DB itself is around 2GB, which isn’t an issue, but it’s from a multisite install that has about 190 sites, and the number of tables in the database is massive. We’re only using this DB for a migration/export and not trying to run it as a site, just some WP-CLI commands.

It appears the startup for this database takes longer than the mysqladmin ping allows. Snips from the logs:

{“level”:“error”,“message”:“Database did NOT respond to ping after 15 tries.”,“service”:{},“serviceBinVersion”:{},“stack”:"Error: Command failed: %%userDataPath%%/lightning-services/mysql-8.0.16+6/bin/darwin/bin/mysqladmin ping

However, a short time after this, mysql starts successfully. I’ve been able to open the site shell and running “mysql” will connect just fine.

{“class”:“Process”,“level”:“warn”,“message”:“2024-08-06T21:20:47.145930Z 0 [System] [MY-010931] [Server] %%userDataPath%%/lightning-services/mysql-8.0.16+6/bin/darwin/bin/mysqld: ready for connections
. Version: ‘8.0.16’ socket: ‘%%site.runData%%/mysql/mysqld.sock’ port: 10034 MySQL Community Server - GPL.”

Is there a way to adjust the timeout for the mysqladmin ping command? If I can allow for a longer startup time, it should resolve this issue. I can eventually get the site to start within the Local dashboard, but it takes several tries to get started. Or some way to start mysql manually from the site shell?

Hey @PeteNelson – Welcome to the community forums!

There isn’t a way for you to adjust those things from within Local.

Now, as long as you’re ok with monkeying around with things that shouldn’t be monkeyed with, you might be able to do what you need to do. The MySQL database service is contained in the lightning-services folder within the Local user config folder. This is a compiled service, but since it’s JS, I think you might be able to manually adjust the source code.

  1. Stop all sites and quit Local
  2. Navigate to the MySQL lightning service at ~/Library/Application Support/Local/lightning-services/mysql-8.0.16+6/lib
  3. Back up the MysqlService.js file, just in case
  4. Edit and save either the maxTries or the delay time (see screenshot)
  5. Start Local and try starting the site

I’ve never done this, so I’m not 100% sure this should work, but I think it should. Also, anytime you try to edit this file, you’ll need to first quit Local, save the file, then start Local to load the lightning service.

Can you give that a try and let me know if that works? Obviously, this is super hacky, and any changes here might be blown away with an update, but in theory this should get you where you need to go.

1 Like

Don’t mind monkeying with the code and reapplying changes afterwards. I changed the maxTries to 30 and still wasn’t able to start the database, so I added this in the catch statement:

this._logger.debug(`No database ping response, try ${i}`);

Then ran tail -f ~/Library/Logs/local-lightning-verbose.log in my terminal.

Noticed that $i was being incremented twice. The catch() statement is also incrementing the variable in addition to the for statement, so that might be a minor bug. It should try to ping the database for about 15 seconds, but it’s only trying for about 7-8 seconds.

{"level":"debug","message":"No database ping response, try 0","service":{},"serviceBinVersion":{},"thread":"main","timestamp":"2024-08-28T13:18:22.460Z"}
{"level":"debug","message":"No database ping response, try 2","service":{},"serviceBinVersion":{},"thread":"main","timestamp":"2024-08-28T13:18:23.478Z"}
{"level":"debug","message":"No database ping response, try 4","service":{},"serviceBinVersion":{},"thread":"main","timestamp":"2024-08-28T13:18:24.494Z"}
{"level":"debug","message":"No database ping response, try 6","service":{},"serviceBinVersion":{},"thread":"main","timestamp":"2024-08-28T13:18:25.512Z"}
{"level":"debug","message":"No database ping response, try 8","service":{},"serviceBinVersion":{},"thread":"main","timestamp":"2024-08-28T13:18:26.532Z"}
{"level":"debug","message":"No database ping response, try 10","service":{},"serviceBinVersion":{},"thread":"main","timestamp":"2024-08-28T13:18:27.548Z"}
{"level":"debug","message":"No database ping response, try 12","service":{},"serviceBinVersion":{},"thread":"main","timestamp":"2024-08-28T13:18:28.564Z"}

After removing the increment in the catch statement, and bumping my number of tries to 45 (the db has over 25k tables), it starts up just fine. Thank you!

3 Likes

Glad that got things working, and thanks for zeroing in on a bug! I’ll get something in the backlog to take a closer look.

This topic was automatically closed 36 hours after the last reply. New replies are no longer allowed.