Unusual CPU high usage/overload causing MySQL server failure

You are here:
Estimated reading time: 1 min

Some customers have reported CPU high usage and overload causing slow MySQL queries and even crashing it.

In all cases the problem was not caused by Rey, but instead from other plugins which were making WooCommerce’s and Rey’s transients to constantly refresh.

The Transients API in WordPress is an important tool for developers to cache data instead of constantly run heavy queries to the database, to retrieve the same data. Transients usually expire at a certain timeframe defined by the developer (every hour, day, week etc.), but never every minute or less.

In one instance a certain plugin was running the wc_delete_product_transients method from WooCommerce, every minute. This was forcing WooCommerce to recreate a lot of transients resulting in a lot of parallel processes in the background. Every minute.

In another instance, a plugin was updating batches of products through REST API calls, and again, a lot of transients were cleared resulting in many background processes.

To debug this problem, first install Query Monitor and look for the Transient Updates tab ex: https://d.pr/i/wRHFaE and monitor it for too much activity. You can refresh the page multiple times during a period, for example of 10 minutes. If there are constant transient updates, there is a problem.

A simple method I use for tracing deleted transients is to paste this code snippet https://d.pr/n/GXTu6E into the child theme’s functions.php (or where you want to add custom code). Also, make sure WP_DEBUG and WP_DEBUG_LOG are enabled.

If there’s indeed a problem, the error log should be filled with “deleted transients” entries every minute(s). If this is the case, please seek immediate help to identify what’s causing the deletions. In the code snippet I mentioned there’s a code backtrace in order to locate what keeps deleting transients.

Was this article helpful?
Dislike 0
Views: 15

Suggest article improvements

Please use this form to suggest improvements and report missing or outdated content. Support requests will most likely not be answered and it's best to use the Support Request Form instead. Thanks!