Pergunta

We have so many error happen on website (WordPress and Woocommerce) error log and it will show the following error message

WordPress database error Deadlock found when trying to get lock; try restarting transaction for query DELETE FROM wp_options WHERE option_name LIKE '_transient_wpseo_sitemap_cache_shop_order_%' OR option_name LIKE '_transient_timeout_wpseo_sitemap_cache_shop_order_%' made by require('wp- blog-header.php'), require_once('wp-includes/template-loader.php'), include('/themes/themename/template/template-name.php'), WC_Abstract_Order->update_status, wp_update_post, wp_insert_post, clean_post_cache, clean_object_term_cache, do_action('clean_object_term_cache'), call_user_func_array, wpseo_invalidate_sitemap_cache_terms, wpseo_invalidate_sitemap_cache, WPSEO_Utils::clear_sitemap_cache

But I don't know why it is happening. I create this template for special operation, and in that template I didn't use get_header(), get_footer() etc

And _transient_wpseo_sitemap_cache_shop_order_% is made by yoast plugin , but I already do not follow instruction for that page

enter image description here

Could any one tell what is the reason for this ?

Also when I install Delete Expired Transients plugin it will show very large number of Expired transients, could any one tell what happen if I delete this expired transient?

Why transient come in my newly created page and template ,even i didn't use get_header(), get_footer() ?

How to disable this future in selected pages ?

Foi útil?

Solução

Transient are not always deleted when they expire, and that makes them unpredictable and sometimes a pain. Whenever I work with transients, I add some kind of functionality to delete the transients when something happens, like I delete transients when publishing posts or updating them if the transient was meant to keep data related to posts.

There is no harm in deleting old expired transients, not even newly created ones. Any transient that is necessary or required will be recreated on the next page load. Because transients are a bit more expensive to create, it might slow one page load down if you delete and recreate all transients in one go. Thereafter everything should work normal again

EDIT

...is there any option to disable all transient in one page or selected pages

No, there is not, and it would be suicide to do that. Most of the transients that are set are done by WordPress by default. WordPress uses these transients to save the results from quite expensive operations. This way, these expensive operations (which will slow your page loads times) do not need to run on every page load, but only once every few days which saves a lot on resources.

As I already stated in a comment, you probably have issues with transients sets by your plugins, in which case you should contact the plugin authors with the relevant debugging info

Outras dicas

It is not a popular opinion, but IMO transients should be avoided if you don't have object caching.

What is happening here (and it is mostly a guess) is that you have two simultaneous attempts to write to the options table. I guess one is an insert and the other is deleted and both need the same resources but one prevents the other to gain control of all the resources it needs and wise versa and therefor neither completes.

What you can try to do is use object caching to avoid transients being saved to the DB, or try to give your DB more power in hope that making it faster will prevent this situation from occurring.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a wordpress.stackexchange
scroll top