Plugin Author
Paul
(@paultgoodchild)
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
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.
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
(@paultgoodchild)
Hi Seb,
I believe using WordPress’ Debug constant 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.
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://ww.wp.xz.cn/plugins/query-monitor/
All the best,
Seb
Plugin Author
Paul
(@paultgoodchild)
Yep, that’s a great plugin. Keep us posted, please, Seb. Thanks!
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…
[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
@frafor
Does the error stop if you disable the Shield Security plugin?