Title: Plugin is causing regular database errors
Last modified: November 22, 2023

---

# Plugin is causing regular database errors

 *  Resolved [seb30303](https://wordpress.org/support/users/seb30303/)
 * (@seb30303)
 * [2 years, 6 months ago](https://wordpress.org/support/topic/plugin-is-causing-regular-database-errors/)
 * Recently we’ve seen regular errors appearing in our log files which look like
   they are caused by the Shield Security plugin not freeing the mysql connection
   after use. We have a very minimal system, no cache plugins, etc. and have checked
   other possible causes for this error, such as out of memory problem. Everything
   points to Shield Security plugin. Hopefully this is the right place to report
   the bug. Here is the latest error log:
 * `[22-Nov-2023 03:04:18 UTC] WordPress database error Commands out of sync; you
   can't run this command now for query UPDATE ``wp_options` SET `option_value` 
   = 'a:19:{s:10:\"17c091668c\";i:1700622257;s:10:\"1d4798ed31\";i:1700622257;s:
   10:\"30f50e695f\";i:1700622257;s:10:\"4975cbdf40\";i:1700622257;s:10:\"4a65c4deff\";
   i:1700622257;s:10:\"4af4b6e936\";i:1700622257;s:10:\"524e230493\";i:1700622257;
   s:10:\"5c95c94e02\";i:1700622257;s:10:\"640e235288\";i:1700622257;s:10:\"80977bcd62\";
   i:1700622257;s:10:\"a266f5e0d2\";i:1700622257;s:10:\"a7a9893b43\";i:1700622257;
   s:10:\"aa8fa913ea\";i:1700622257;s:10:\"aba884e9af\";i:1700622257;s:10:\"c46e22039b\";
   i:1700622257;s:10:\"c6cc05baaa\";i:1700622257;s:10:\"c8fea9cab1\";i:1700622257;
   s:10:\"caa308b9e8\";i:1700622257;s:10:\"e06701ecf6\";i:1700622257;}' WHERE `option_name`
   = 'apto-dbs-ready-status' made by shutdown_action_hook, do_action('shutdown'),
   WP_Hook->do_action, WP_Hook->apply_filters, FernleafSystems\Wordpress\Plugin\
   Core\Databases\Common\TableReadyCache->save, FernleafSystems\Wordpress\Services\
   Core\General->updateOption, update_option

Viewing 7 replies - 1 through 7 (of 7 total)

 *  Plugin Author [Paul](https://wordpress.org/support/users/paultgoodchild/)
 * (@paultgoodchild)
 * [2 years, 6 months ago](https://wordpress.org/support/topic/plugin-is-causing-regular-database-errors/#post-17222961)
 * Hi,
 * Thanks for reaching out to us about this.
 * The problem is actually the other way about – the MySQL query fails because the
   commands are you out of sync – something else is knocking them out of sync and
   then when Shield tries to execute the MySQL update, it doesn’t work.
 * If you read the error closely it says it can’t run that command just now because
   of the state of the system. This pops up every now and again, not just for Shield:
 * [https://www.google.com/search?q=WordPress+database+error+Commands+out+of+sync](https://www.google.com/search?q=WordPress+database+error+Commands+out+of+sync)
 * It’s almost impossible to know where the cause lies in each particular case… 
   you could try selectively disabling 1 plugin on your site for a short while to
   see if the errors stop, but due to the inconsistent and psuedo-random nature 
   of this error, it’ll be hard to pinpoint it.
 * Another option might be to temporarily upgrade your server hosting assuming it
   upgrades your MySQL capacity and see if given your MySQL more power helps with
   preventing the error.
 * I appreciate this isn’t the result you’d like to hear, but it’s all we can suggest
   at this stage.
 *  Thread Starter [seb30303](https://wordpress.org/support/users/seb30303/)
 * (@seb30303)
 * [2 years, 6 months ago](https://wordpress.org/support/topic/plugin-is-causing-regular-database-errors/#post-17223923)
 * Hi Paul,
 * Thanks for the quick reply. I realise that this error occurs in the *next* database
   query after an incomplete query using mode MYSQLI_USE_RESULT, where either the
   full query didn’t get read or mysqli_result::free() wasn’t called.
 * I still strongly suspect the Shield Security plugin as it is doing the query 
   literally every time this error occurs, so it’s fair to assume it’s the most 
   likely candidate to have done the previous query.
 * Also, aside from the core WordPress itself, it is the only thing which has updated
   recently on the server. The only other plugins present are Akismet Anti-spam 
   and XML Sitemap Generator for Google. The WordPress site is actually quite a 
   small / low traffic site which lives on a powerful VPS (many GB), mainly used
   for hosting other things.
 * Anyway, I thought I’d let you know in case you want to check the recent changes
   in your code.
 * I’ll keep an eye on the error and see if we can narrow down the cause more specifically.
   Do you know if it’s possible to enable logging of database queries within WordPress
   so we can find the preceding query?
 * Thank you,
   Seb
 *  Plugin Author [Paul](https://wordpress.org/support/users/paultgoodchild/)
 * (@paultgoodchild)
 * [2 years, 6 months ago](https://wordpress.org/support/topic/plugin-is-causing-regular-database-errors/#post-17224042)
 * Hi Seb,
 * I believe using [WordPress’ Debug constant](https://wordpress.org/documentation/article/debugging-in-wordpress/#wp_debug)
   will increase logging and include DB logging… you may need to confirm that.
 * But yes, if you can find the query that preceeds it, it might help, but… I’m 
   not honestly sure what we could do to affect change – we’re making use of WordPress’
   DB class to handle all these queries for us, so I’m not sure why suddenly it 
   wouldn’t be doing so properly. The alternative is to then force cleanup after
   queries each time, and I’m not sure how reliable/effective/performant that would
   be.
 * Anyway, hopefully you can find some more info in the debug and we can take it
   from there. It’s hard to know more without seeing what’s preceeding these calls.
 *  Thread Starter [seb30303](https://wordpress.org/support/users/seb30303/)
 * (@seb30303)
 * [2 years, 6 months ago](https://wordpress.org/support/topic/plugin-is-causing-regular-database-errors/#post-17224504)
 * Hi Paul,
 * Thanks again for your reply.
 * I’m not particularly familiar with the internals of WordPress but if you are 
   using their DB class then one would think that it should take care of the low
   level stuff like freeing query results.
 * I will add some more logging and see if we can get to the bottom of it. If there’s
   anything relevant to Shield Security, I’ll update this thread.
 * I couldn’t see any WP constant which would enabled database query logging – only
   SAVEQUERIES which saves queries to an array. But there was a link to this plugin
   which looks like it will do the job: [https://wordpress.org/plugins/query-monitor/](https://wordpress.org/plugins/query-monitor/)
 * All the best,
   Seb
 *  Plugin Author [Paul](https://wordpress.org/support/users/paultgoodchild/)
 * (@paultgoodchild)
 * [2 years, 6 months ago](https://wordpress.org/support/topic/plugin-is-causing-regular-database-errors/#post-17224572)
 * Yep, that’s a great plugin. Keep us posted, please, Seb. Thanks!
 *  [frafor](https://wordpress.org/support/users/frafor/)
 * (@frafor)
 * [2 years, 3 months ago](https://wordpress.org/support/topic/plugin-is-causing-regular-database-errors/#post-17425133)
 * Hi there, I am having the same exact db error on a website of my which is just
   hosting a landing page at the moment, so there’s nothing complex on it…
 *     ```wp-block-code
       [12-Feb-2024 16:45:54 UTC] WordPress database error Commands out of sync; you can't run this command now for query UPDATE wp_options SET option_value = 'a:19:{s:10:\"127e677c8d\";i:1707756353;s:10:\"188ebe03c3\";i:1707756353;s:10:\"28d903f7ed\";i:1707756353;s:10:\"47ea943e39\";i:1707756353;s:10:\"4ad1ffa77a\";i:1707756353;s:10:\"655840fb76\";i:1707756353;s:10:\"77230c6457\";i:1707756353;s:10:\"7912f2e30f\";i:1707756353;s:10:\"8a99975c88\";i:1707756353;s:10:\"962eaf65b9\";i:1707756353;s:10:\"9da8092e03\";i:1707756353;s:10:\"ab90d271d0\";i:1707756353;s:10:\"b3f7345be7\";i:1707756353;s:10:\"cabbb5f088\";i:1707756353;s:10:\"ce8a0064d3\";i:1707756353;s:10:\"cf3927860d\";i:1707756353;s:10:\"dad3af107f\";i:1707756353;s:10:\"ecac7f51dd\";i:1707756353;s:10:\"f8bf733f55\";i:1707756353;}' WHERE option_name = 'apto-dbs-ready-status' made by shutdown_action_hook, do_action('shutdown'), WP_Hook->do_action, WP_Hook->apply_filters, FernleafSystems\Wordpress\Plugin\Core\Databases\Common\TableReadyCache->save, FernleafSystems\Wordpress\Services\Core\General->updateOption, update_option
       [14-Feb-2024 03:46:12 UTC] WordPress database error Commands out of sync; you can't run this command now for query UPDATE wp_options SET option_value = 'a:19:{s:10:\"127e677c8d\";i:1707882371;s:10:\"188ebe03c3\";i:1707882371;s:10:\"28d903f7ed\";i:1707882371;s:10:\"47ea943e39\";i:1707882371;s:10:\"4ad1ffa77a\";i:1707882371;s:10:\"655840fb76\";i:1707882371;s:10:\"77230c6457\";i:1707882371;s:10:\"7912f2e30f\";i:1707882371;s:10:\"8a99975c88\";i:1707882371;s:10:\"962eaf65b9\";i:1707882371;s:10:\"9da8092e03\";i:1707882371;s:10:\"ab90d271d0\";i:1707882371;s:10:\"b3f7345be7\";i:1707882371;s:10:\"cabbb5f088\";i:1707882371;s:10:\"ce8a0064d3\";i:1707882371;s:10:\"cf3927860d\";i:1707882371;s:10:\"dad3af107f\";i:1707882371;s:10:\"ecac7f51dd\";i:1707882371;s:10:\"f8bf733f55\";i:1707882371;}' WHERE option_name = 'apto-dbs-ready-status' made by shutdown_action_hook, do_action('shutdown'), WP_Hook->do_action, WP_Hook->apply_filters, FernleafSystems\Wordpress\Plugin\Core\Databases\Common\TableReadyCache->save, FernleafSystems\Wordpress\Services\Core\General->updateOption, update_option
       ```
   
 *  Thread Starter [seb30303](https://wordpress.org/support/users/seb30303/)
 * (@seb30303)
 * [2 years, 3 months ago](https://wordpress.org/support/topic/plugin-is-causing-regular-database-errors/#post-17430595)
 * [@frafor](https://wordpress.org/support/users/frafor/)
 * Does the error stop if you disable the Shield Security plugin?

Viewing 7 replies - 1 through 7 (of 7 total)

The topic ‘Plugin is causing regular database errors’ is closed to new replies.

 * ![](https://ps.w.org/wp-simple-firewall/assets/icon-256x256.png?rev=3054572)
 * [Shield Security – Smart Bot Blocking, Brute-Force Login Protection & File Scanning](https://wordpress.org/plugins/wp-simple-firewall/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wp-simple-firewall/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wp-simple-firewall/)
 * [Active Topics](https://wordpress.org/support/plugin/wp-simple-firewall/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wp-simple-firewall/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wp-simple-firewall/reviews/)

 * 7 replies
 * 3 participants
 * Last reply from: [seb30303](https://wordpress.org/support/users/seb30303/)
 * Last activity: [2 years, 3 months ago](https://wordpress.org/support/topic/plugin-is-causing-regular-database-errors/#post-17430595)
 * Status: resolved