You are here
Home > Latest Posts > How To & Mods > Solving Server load issue caused by WordPress 4.3 update bug

Solving Server load issue caused by WordPress 4.3 update bug

Load server

After updating to WordPress‘s latest 4.3 update, me and my Server have been under very high stress and load (pun intended) for about 10 days. The server load jumped as if there has been a DDOS attack and all of 4 GB RAM of my VPS was chewed.

RAM Load

It was hard to detect what has gone wrong and we checked all possible reasons starting from misconfiguration to traffic to infection to DDOS attack. Ultimately after 9 days of suffering, after scanning through the WordPress forums, I got the solution and it worked perfectly bringing my server load and RAM usage to normal levels like before. The issue is with a bug with WordPress 4.3 that causes reversal of arguments for “Cron entries”, creating huge number of Cron jobs leading to server load and RAM plugging.

Two step fix of load issue caused by WordPress 4.3 bug:

If you can access File Manager from your CPanel and know what you are doing, do it yourself, or else take help of your hosting provider’s support team.

Step 1:

Fix the actual issue by applying part of the patch in that ticket. It’s a one liner. Open the wp-includes/taxonomy.php file, and go to line 4448. This is that line:

wp_schedule_single_event( ‘wp_batch_split_terms’, time() + MINUTE_IN_SECONDS );

The problem is that the arguments are reversed. Switch them, like so:

wp_schedule_single_event( time() + MINUTE_IN_SECONDS, ‘wp_batch_split_terms’ );

That will fix the underlying issue, but it won’t stop the load. To do that, we’re going to make a temporary mu-plugin.

Step 2:

Navigate to your /wp-content directory. Create a subdirectory called “mu-plugins”, at /wp-content/mu-plugins. The name of the directory is important. If you already have that directory, just go in there.

MU Plugins are “must use”. All PHP files in this directory get auto-included by WordPress. It’s a handy way to run some code in your WordPress instance without having access to the Plugin page to activate plugins.

Create a new file called “fix.php”. Or anything, the name doesn’t matter. This will be the contents of that file:

<?php
function clear_bad_cron_entries() {
// Fix incorrect cron entries for term splitting
$cron_array = _get_cron_array();
if ( isset( $cron_array[‘wp_batch_split_terms’] ) ) {
unset( $cron_array[‘wp_batch_split_terms’] );
_set_cron_array( $cron_array );
}
}
clear_bad_cron_entries();

As per the WordPress developers, above code is the same code coming with WordPress’s next update 4.3.1 to clean up the problem. You need it to run now instead for fixing your sever load issue. So paste that code into the fix.php file, and save.

Now, navigate to your site. The problem should clear up shortly. Once it does, you can delete the fix.php file. It only needs to run once, not every time your site loads.

If you are using multi-site, then you need to load every site at least once to allow this code to run on all of them. Cron jobs are stored per-site, not per-instance.

The solution worked like a charm in our case. So, follow the instructions carefully or let you hosting provider do it for you. In case you are getting Memory allocation error, viz: “Fatal error: Allowed memory size of XXXXXXX bytes exhausted (tried to allocate XXXX bytes)” after updating to WordPress 4.3, you may face above issue later, as in our case it started with memory allocation error only. So, in case you have memory allocation error or huge server load try checking your wp-includes/taxonomy.php file as per step 1.

Source

Nayan
Nayan has more than 10 years of experience of covering Technology and innovations. He is a big Nokia fan and Tech disruptions aficionado. He loves to review new cool gadgets and writing about Android, iOS, Gadgets and general Technology stuff. He has been associated with other well-known Tech sites WinCentral and Nokiapoweruser since long. He currently sports a Lumia 950 XL and Nexus 5X. Other interests include listening to Nu-Metal Hits and Kick-Boxing. Write to him at Email: [email protected]
Top