Skip Navigation

This thread is resolved. Here is a description of the problem and solution.

Problem:
The client is experiencing database deadlocks when WPML is enabled, which floods the error log. Clearing the WPML cache temporarily resolves the issue, and the client inquires about the effectiveness of clearing the cache and the impact of using the Advance Translator over the Classic one.
Solution:
If you're experiencing database deadlocks similar to the ones described, we recommend following the workaround provided in our errata page: https://wpml.org/errata/wpml-causing-backend-slowness-and-duplicated-queries/. Clearing the WPML cache can sometimes help because it removes temporary data that could be causing a bottleneck. As for the translator mode, switching to the Advanced Translator can improve performance as it is optimized for better efficiency.

Please note that the solution provided might be outdated or not applicable to your case. We highly recommend checking related known issues at https://wpml.org/known-issues/, verifying the version of the permanent fix, and confirming that you have installed the latest versions of themes and plugins. If the problem persists, please open a new support ticket: WPML support forum.

This is the technical support forum for WPML - the multilingual WordPress plugin.

Everyone can read, but only WPML clients can post here. WPML team is replying on the forum 6 days per week, 22 hours per day.

No supporters are available to work today on this forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

Tagged: 

This topic contains 15 replies, has 3 voices.

Last updated by Dražen Duvnjak 9 months, 1 week ago.

Assisted by: Dražen Duvnjak.

Author Posts
January 29, 2024 at 5:01 pm #15240011

garethM-3

I raised a support ticket recently which has been closed so I can no longer add to it (https://wpml.org/forums/topic/experiencing-database-deadlocks-intermittently/) I am experiencing the same problem again. When I enabled WPML it eventually will cease up and flood my error log with Deadlocks:

WordPress database error Deadlock found when trying to get lock; try restarting transaction for query INSERT IGNORE INTO wp_options ( `option_name`, `option_value`, `autoload` ) VALUES ('wpml.WPML\\\\TM\\\\Settings\\\\ProcessNewTranslatableFields.lock', '1706483353', 'no') /* LOCK */ made by require_once('wp-load.php'), require_once('/home/orthoracle/orthoracle.com/releases/20240125195731/wp-config.php'), require_once('wp-settings.php'), do_action('wp_loaded'), WP_Hook->do_action, WP_Hook->apply_filters, WPML\\LIB\\WP\\Hooks::WPML\\LIB\\WP\\{closure}, WPML\\FP\\Promise->resolve, WPML\\FP\\Right->chain, WPML\\FP\\Right->map, WPML\\BackgroundTask\\BackgroundTaskLoader->WPML\\BackgroundTask\\{closure}, WPML\\BackgroundTask\\BackgroundTaskLoader->getSerializedTasks, WPML\\FP\\Fns::__callStatic, call_user_func_array, WPML\\FP\\Fns::WPML\\FP\\{closure}, call_user_func_array, WPML\\FP\\Fns::WPML\\FP\\{closure}, array_map, WPML\\BackgroundTask\\BackgroundTaskLoader->WPML\\BackgroundTask\\{closure}, WPML\\BackgroundTask\\BackgroundTaskViewModel::get, WPML\\Utilities\\Lock->create, WPML\\Utilities\\Lock->create, WPML\\Utilities\\Lock->create, WPML\\Utilities\\Lock->create, WPML\\Utilities\\Lock->create, referer: hidden link

It seems I am not alone in experiencing this problem as I found the following support tickets from other users experiencing deadlocks:

- https://wpml.org/forums/topic/deadlock-errors-in-website-logs/
- https://wpml.org/forums/topic/got-error-php-message-wordpress-database-error-deadlock/
- https://wpml.org/forums/topic/wordpress-database-error-deadlock-3/
- https://wpml.org/forums/topic/wordpress-database-error-deadlock-found-when-trying-to-get-lock-try-restarting/

Most of the advice given on these tickets says to clear the WPML cache, which I have done and it seems to solve the problem briefly. I even set up a cronjob to clear the WPML cache once a week but this didn't help. Perhaps I should clear the cache once a day?

Since the solution provided is always to clear the cache, perhaps you could explain why clearing the cache can sometimes help? What is this wp_options query doing?

Another solution offered was to make sure the Advance Translator is enabled. Currently we have the Classic one enabled. Can you tell me why this should make a difference?

Thank you in advance.

January 30, 2024 at 10:45 am #15242686

Alejandro
Supporter

Languages: English (English ) Spanish (Español ) Italian (Italiano )

Timezone: Europe/Rome (GMT+01:00)

Hello!

I'll try to help you out while a supporter takes your case.

The deadlock issue is usually a server-related problem. in this case i can see that the problem happened not on one of our tables but while loading an option that happened to be ours.

Can you please ask your hosting if they have more information about this deadlock? maybe i happened because ack of memory, maybe the option was too big or something.

We may be able to help more with extra info since, again, this issue is very specific to your hosting and its database.

January 30, 2024 at 2:41 pm #15244527

garethM-3

I will get that information to you. However did you notice it was this same query that was causing issues in the other support threads I posted?

January 31, 2024 at 9:36 am #15248184

Dražen Duvnjak
Supporter

Languages: English (English )

Timezone: Europe/Zagreb (GMT+01:00)

Hello,

thanks for getting back.

This seems to be a known issue and we are working on a permanent fix, can you please follow the workaround from the next errata:

- https://wpml.org/errata/wpml-causing-backend-slowness-and-duplicated-queries/

Regards,
Drazen

January 31, 2024 at 2:30 pm #15249863

garethM-3

That's good to know you are working on a permanent fix.

I have tried that fix before which works, but after a few days we experiences the same deadlock. Would you recommend perhaps truncating the icl_background_task table every day? Would this negatively affect the plugin?

January 31, 2024 at 5:09 pm #15250787

garethM-3

I just re-enabled your plugin and it brought my site down immediately. My error log is full of Deadlocks again:

WordPress database error Deadlock found when trying to get lock; try restarting transaction for query DELETE FROM wp_icl_translations\n\t\t\t\t\t WHERE element_type = 'post_sfwd-quiz'\n\t\t\t\t AND element_id = 666589 made by require_once('wp-load.php'), require_once('/home/orthoracle/orthoracle.com/releases/20240131160823/wp-config.php'), require_once('wp-settings.php'), do_action('init'), WP_Hook->do_action, WP_Hook->apply_filters, SitePress->rebuild_language_information, TranslationManagement->add_missing_language_information, TranslationManagement->add_missing_language_to_posts, TranslationManagement->add_missing_language_to_post, SitePress->set_element_language_details, WPML_Set_Language->set, WPML_Set_Language->delete_existing_row, referer: hidden link

Can you tell me what tasks the plugin executes on activation? Does it try to index anything at that point?

February 1, 2024 at 7:24 am #15253017

Dražen Duvnjak
Supporter

Languages: English (English )

Timezone: Europe/Zagreb (GMT+01:00)

Hello,

I think it would be safe to trunk key value on a regular basis. One of the reasons could be that the cron job that removes this entry and rechecks it correctly is not working on your website/server.

What this does is re-check any translation job, try to run a job, then fail remove the key, and try to re-create the key again, so it gets filled with data.

With ATE editor this works and data is removed and jobs re-checked correctly.

Hope this helps.

Regards,
Drazen

February 1, 2024 at 3:15 pm #15255574

garethM-3

The site cron is disabled on our site and instead triggered via a crontask which hits wp-cron.php every 2 mins. We know this is working as we're using Woo Subscriptions and this is all functioning OK.

You say "With ATE editor this works and data is removed and jobs re-checked correctly." Are you saying if we use the Classic Editor translator (which we are) there might be problems?

February 2, 2024 at 7:13 am #15257976

Dražen Duvnjak
Supporter

Languages: English (English )

Timezone: Europe/Zagreb (GMT+01:00)

Hello,

I am saying this issue happens when using CTE for translation and with ATE, as I can see in our dev ticket it should work fine and this issue shouldn't happen.

Regards,
Drazen

February 4, 2024 at 9:42 pm #15263975

garethM-3

Unfortunately this issue still persists, and I see another user recently posted about a deadlock too https://wpml.org/forums/topic/wordpress-database-error-deadlock-found-2/

With a heavy hear we having to research alternative multi language plugins 🙁

February 5, 2024 at 7:50 am #15264394

Dražen Duvnjak
Supporter

Languages: English (English )

Timezone: Europe/Zagreb (GMT+01:00)

Hello,

1) as I understood removing the key as I suggested above helps and solves the issue, at least temporarily, is that correct? If so, does removing the key again help?

2) Also do you have a staging site where you can do some further tests?

3) In order to expedite handling your support requests, can you please share WPML support debug information from your site.

- To give debug information, login to your site and go to WPML → Support. From there click on the “debug information” link at the bottom of the page.
- Once on the “debug information” page, select the entire content of the text box and copy it.
- Now go back to our support forum, find debug information box and paste it.

More information on the link: https://wpml.org/faq/provide-debug-information-faster-support/

Thanks,
Drazen

February 5, 2024 at 3:06 pm #15266837
garethM-3

Hi,

1) The previous solutions did used to work temporarily, but now I can't even enable WPML without it bringing my whole site down. I truncated the wp_icl_background_task before enabling the plugin but it had no effect.

2) I will duplicate the live website to our staging server and get you access ASAP.

3) I can't get you the WPML debug information from the live server without enabling the plugin which breaks the website. What I have done is get that information from my laptop version of the site that has identical plugins and WordPress version. I hope that helps somewhat?

New threads created by Dražen Duvnjak and linked to this one are listed below:

https://wpml.org/forums/topic/split-wpml-bringing-my-whole-site-down/

February 6, 2024 at 12:12 am #15268612

garethM-3

I need to send you login details for the staging site, can you open a private chat?

February 6, 2024 at 7:32 am #15269122

Dražen Duvnjak
Supporter

Languages: English (English )

Timezone: Europe/Zagreb (GMT+01:00)

Hello,

thanks.

This looks like a different issue then the one originally reported and the one related to ProcessNewTranslatableFields.lock as the error is different (try restarting transaction for query DELETE FROM wp_icl_translations\n\t\t\t\t\t ) and your website is not working at all.

To keep the ticket clear and on point and since we limit 1 issue per ticket, I have opened a new ticket and will update you further there:

- https://wpml.org/forums/topic/split-wpml-bringing-my-whole-site-down/

Regards,
Drazen

February 9, 2024 at 2:36 pm #15286564

garethM-3

The support bot trying to close this ticket as we're not talking on the second ticket. However I still cannot enable the plugin without it bringing down my site. This may be a different deadlock query, but it's still a deadlock that's breaking my site.

I will finish supplying access details to my client site in the second ticket