Multisite Freezing a Lot

Bear with this long explanation, I feel it illustrates what seems more like an issue with Local than WordPress directly, and one I’m at a loss for fixing so could use advice about…

For the past few months now one specific site in Local for me has been “freezing” a lot. Sometimes every other page load, making development with it painful. This is the only multisite network install I have on Local, being a clone of a client site with 19 sites on the network, using the subdirectory network mode. When this happens I’ve had to restart the site, but this should not happen or be necessary to restart for this. Today I decided to dig further into what is happening, and it feels like some kind of issue brought on by Local (in part because the live website has never had anything like this happen).

Visually when the site “freezes” it is when I’m loading a page (I’ve documented this today on every kind of subsite and both in the frontend and dashboard), the progress indicator for the load in Safari gets stuck. This is when I usually restart the site. In looking deeper today I noticed that the site’s (“rea.local” is the site domain; “rea2022” a subsite) nginx error.log had the following at the time of this freeze:

2021/11/12 09:43:40 [error] 71402#0: *151 upstream prematurely closed connection while reading response header from upstream, client: 127.0.0.1, server: , request: "GET /rea2022/call/ HTTP/1.0", upstream: "fastcgi://unix:/Users/alex/Library/Application Support/Local/run/TH_Lg4h5t/php/php-fpm.socket:", host: "rea.local", referrer: "https://rea.local/rea2022/"

At the time I was on the front page of that site, and had clicked a link to another page on the site. Restarting the site cleared things up for a short bit.

I continued to poke around, again, trying to trigger this precisely so I can debug it and/or (as this very post is) ask about it here. After logging in to the site I eventually (after enabling a plugin at the network level) run into another freeze when clicking the “Drop-ins” tab of that page in the Dashboard. Although, this time no log entry appears in the aforementioned log file. It took a while to show that page, although I hadn’t counted the time. I did look at log files, and almost felt like that act alone may have tripped the site into action again. So I go to load the main site’s home page, and this load took 4 minutes, no log entries anywhere to be found.

This kind of poking around I did for a while where about 50% of page loads are abnormally long (upwards of 4 minutes on average). It feels to me like something deep in Local is “stuck”, using my expertise as a web and app developer to guide me. Out of the blue about half an hour later when poking around triggering freezes I find myself with the “Error establishing a database connection” page. I had not seen more upstream prematurely closed log entries added, or any at freeze times in any log files. I tested the database in TablePlus, and yep, it is not there. So, another restart of this site has to ensue, although this time due to the database. Log entries for this run of the site from php-fpm.log:

[12-Nov-2021 09:43:42] NOTICE: fpm is running, pid 71457
[12-Nov-2021 09:43:42] NOTICE: ready to handle connections
[12-Nov-2021 10:59:03] NOTICE: Terminating ...
[12-Nov-2021 10:59:03] NOTICE: Terminating ...
[12-Nov-2021 10:59:03] NOTICE: exiting, bye-bye!

At the same time, the local-lightning.log file showed the following:

{"thread":"main","class":"Process","process":"mysql","level":"warn","message":"2021-11-12T16:57:09.625929Z 0 [Warning] File Descriptor 1133 exceeded FD_SETSIZE=1024","timestamp":"2021-11-12T16:57:09.626Z"}

Similarly, in a debug.log file that I have where all WP_DEBUG output lands at the time of the database failure are numerous entries like these:

[12-Nov-2021 16:59:01 UTC] PHP Warning:  mysqli_real_connect(): Error while reading greeting packet. PID=71460 in /Users/alex/Programming/LocalSites/rea/app/public/wp-includes/wp-db.php on line 1653
[12-Nov-2021 16:59:01 UTC] PHP Stack trace:
[12-Nov-2021 16:59:01 UTC] PHP   1. {main}() /Users/alex/Programming/LocalSites/rea/app/public/wp-includes/ms-files.php:0
[12-Nov-2021 16:59:01 UTC] PHP   2. require_once() /Users/alex/Programming/LocalSites/rea/app/public/wp-includes/ms-files.php:12
[12-Nov-2021 16:59:01 UTC] PHP   3. require_once() /Users/alex/Programming/LocalSites/rea/app/public/wp-load.php:50
[12-Nov-2021 16:59:01 UTC] PHP   4. require_once() /Users/alex/Programming/LocalSites/rea/app/public/wp-config.php:104
[12-Nov-2021 16:59:01 UTC] PHP   5. require_wp_db() /Users/alex/Programming/LocalSites/rea/app/public/wp-settings.php:124
[12-Nov-2021 16:59:01 UTC] PHP   6. wpdb->__construct() /Users/alex/Programming/LocalSites/rea/app/public/wp-includes/load.php:558
[12-Nov-2021 16:59:01 UTC] PHP   7. wpdb->db_connect() /Users/alex/Programming/LocalSites/rea/app/public/wp-includes/wp-db.php:632
[12-Nov-2021 16:59:01 UTC] PHP   8. mysqli_real_connect() /Users/alex/Programming/LocalSites/rea/app/public/wp-includes/wp-db.php:1653
[12-Nov-2021 16:59:01 UTC] PHP Warning:  mysqli_real_connect(): (HY000/2006): MySQL server has gone away in /Users/alex/Programming/LocalSites/rea/app/public/wp-includes/wp-db.php on line 1653
[12-Nov-2021 16:59:01 UTC] PHP Stack trace:
[12-Nov-2021 16:59:01 UTC] PHP   1. {main}() /Users/alex/Programming/LocalSites/rea/app/public/wp-includes/ms-files.php:0
[12-Nov-2021 16:59:01 UTC] PHP   2. require_once() /Users/alex/Programming/LocalSites/rea/app/public/wp-includes/ms-files.php:12
[12-Nov-2021 16:59:01 UTC] PHP   3. require_once() /Users/alex/Programming/LocalSites/rea/app/public/wp-load.php:50
[12-Nov-2021 16:59:01 UTC] PHP   4. require_once() /Users/alex/Programming/LocalSites/rea/app/public/wp-config.php:104
[12-Nov-2021 16:59:01 UTC] PHP   5. require_wp_db() /Users/alex/Programming/LocalSites/rea/app/public/wp-settings.php:124
[12-Nov-2021 16:59:01 UTC] PHP   6. wpdb->__construct() /Users/alex/Programming/LocalSites/rea/app/public/wp-includes/load.php:558
[12-Nov-2021 16:59:01 UTC] PHP   7. wpdb->db_connect() /Users/alex/Programming/LocalSites/rea/app/public/wp-includes/wp-db.php:632
[12-Nov-2021 16:59:01 UTC] PHP   8. mysqli_real_connect() /Users/alex/Programming/LocalSites/rea/app/public/wp-includes/wp-db.php:1653

At this point I’m sure that many of the times these past few months I’ve restarted the site if I’d waited minutes it’d have loaded (but when testing PHP and Javascript code who wants to wait minutes…). But such long load times, and the upstream prematurely closed log entries, feel more like Local is the issue than WordPress to me.

My configuration (understanding that these are current versions, but with this happening for months, so earlier versions were also affected):

  • macOS Monterrey 12.0.1 on an M1 Mac mini (although my partner’s Intel iMac is seeing the same issue, on the same macOS versions)
  • Local 6.1.5+5536

The site in question is the only site that has this problem out of 15 I have in Local, but it is also the only network I have in Local. It is using PHP 7.4.1, MySQL 5.7.28, WordPress 5.8.2, and is a Subdirectories multisite. I have rebuilt the site in Local entirely from scratch (aside from wp-content and a database dump being imported, of course), but it would be hard to generate a test site for this, given the complexity of this network site. I also cannot share an export of this site in its entirety to Local staff because of the sensitive nature of some of the user information in the database. The site includes numerous plugins, a bunch of which are custom for this client, and a custom theme.

Does anyone know what kind of thing may be so consistently causing these “freezes” while leaving no clear pattern of what pages freeze on load, what is on them (so what plugins are in force, etc.), or any hint as to lines of code triggering this based on WP_DEBUG output? It feels too random to be directly WordPress, which is why I’m asking here with the feeling that it is somehow Local itself at fault. Thanks in advance for any advice or hints you can give me.

I still want to get to the bottom of why this site is freezing. The more I think about it the more I wonder if MySQL debug logging may hint at something, but not sure how to enable such a thing in Local.

In the meantime to not frustrate myself when developing in this site I’ve written a plugin that works to automate restarting the site. It is a crude bandaid, and I’m sure can be improved, but with limited testing this afternoon since I completed it seems like it may at least do the trick. Of course, restarting is a bandaid entirely, ideally someone can help point me to a way to further debug the actual root problem.

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