- 🇦🇹Austria drunken monkey Vienna, Austria
Thanks for the information!
It’s weird if it also happens for MariaDB, as that’s both automatically tested and the DBMS used by me. Does it always happen when rebuilding Views data, or just sometimes, or maybe even reliably under some circumstances?
If it happens somewhat reliably, would you be able to get me a stack trace? It seems like this is triggered deep in the belly of the Entity API, so unsure whether we can really fix this ourselves. But it might be possible. Getting the same error in logs.
Drupal\Core\Database\DatabaseExceptionWrapper while computing Views data for index AINDEX: SQLSTATE[40001]: Serialization failure: 1213 Deadlock found when trying to get lock; try restarting transaction: INSERT INTO "cache_config" ("cid", "expire", "created", "tags", "checksum", "data", "serialized") VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3, :db_insert_placeholder_4, :db_insert_placeholder_5, :db_insert_placeholder_6), (:db_insert_placeholder_7, :db_insert_placeholder_8, :db_insert_placeholder_9, :db_insert_placeholder_10, :db_insert_placeholder_11, :db_insert_placeholder_12, :db_insert_placeholder_13), (:db_insert_placeholder_14, :db_insert_placeholder_15, :db_insert_placeholder_16, :db_insert_placeholder_17, :db_insert_placeholder_18, :db_insert_placeholder_19, :db_insert_placeholder_20), (:db_insert_placeholder_21, :db_insert_placeholder_22, :db_insert_placeholder_23, :db_insert_placeholder_24, :db_insert_placeholder_25, :db_insert_placeholder_26, :db_insert_placeholder_27), (:db_insert_placeholder_28, :db_insert_placeholder_29, :db_insert_placeholder_30, :db_insert_placeholder_31, :db_insert_placeholder_32, :db_insert_placeholder_33, :db_insert_placeholder_34), (:db_insert_placeholder_35, :db_insert_placeholder_36, :db_insert_placeholder_37, :db_insert_placeholder_38, :db_insert_placeholder_39, :db_insert_placeholder_40, :db_insert_placeholder_41), (:db_insert_placeholder_42, :db_insert_placeholder_43, :db_insert_placeholder_44, :db_insert_placeholder_45, :db_insert_placeholder_46, :db_insert_placeholder_47, :db_insert_placeholder_48), (:db_insert_placeholder_49, :db_insert_placeholder_50, :db_insert_placeholder_51, :db_insert_placeholder_52, :db_insert_placeholder_53, :db_insert_placeholder_54, :db_insert_placeholder_55), (:db_insert_placeholder_56, :db_insert_placeholder_57, :db_insert_placeholder_58, :db_insert_placeholder_59, :db_insert_placeholder_60, :db_insert_placeholder_61, :db_insert_placeholder_62), (:db_insert_placeholder_63, :db_insert_placeholder_64, :db_insert_placeholder_65, :db_insert_placeholder_66, :db_insert_placeholder_67, :db_insert_placeholder_68, :db_insert_placeholder_69), (:db_insert_placeholder_70, :db_insert_placeholder_71, :db_insert_placeholder_72, :db_insert_placeholder_73, :db_insert_placeholder_74, :db_insert_placeholder_75, :db_insert_placeholder_76), (:db_insert_placeholder_77, :db_insert_placeholder_78, :db_insert_placeholder_79, :db_insert_placeholder_80, :db_insert_placeholder_81, :db_insert_placeholder_82, :db_insert_placeholder_83), (:db_insert_placeholder_84, :db_insert_placeholder_85, :db_insert_placeholder_86, :db_insert_placeholder_87, :db_insert_placeholder_88, :db_insert_placeholder_89, :db_insert_placeholder_90), (:db_insert_placeholder_91, :db_insert_placeholder_92, :db_insert_placeholder_93, :db_insert_placeholder_94, :db_insert_placeholder_95, :db_insert_placeholder_96, :db_insert_placeholder_97) ON DUPLICATE KEY UPDATE "cid" = VALUES("cid"), "expire" = VALUES("expire"), "created" = VALUES("created"), "tags" = VALUES("tags"), "checksum" = VALUES("checksum"), "data" = VALUES("data"), "serialized" = VALUES("serialized"); Array ( [:db_insert_placeholder_0] => core.base_field_override.paragraph.related_sidebar_advertisement.id [:db_insert_placeholder_1] => -1 [:db_insert_placeholder_2] => 1676475738.847 [:db_insert_placeholder_3] => [:db_insert_placeholder_4] => 0 [:db_insert_placeholder_5] => b:0; [:db_insert_placeholder_6] => 1 [:db_insert_placeholder_7] => core.base_field_override.paragraph.related_sidebar_advertisement.uuid [:db_insert_placeholder_8] => -1 [:db_insert_placeholder_9] => 1676475738.847 [:db_insert_placeholder_10] => [:db_insert_placeholder_11] => 0 [:db_insert_placeholder_12] => b:0; [:db_insert_placeholder_13] => 1 [:db_insert_placeholder_14] => core.base_field_override.paragraph.related_sidebar_advertisement.revision_id [:db_insert_placeholder_15] => -1 [:db_insert_placeholder_16] => 1676475738.847 [:db_insert_placeholder_17] => [:db_insert_placeholder_18] => 0 [:db_insert_placeholder_19] => b:0; [:db_insert_placeholder_20] => 1 [:db_insert_placeholder_21] => core.base_field_override.paragraph.related_sidebar_advertisement.langcode [:db_insert_placeholder_22] => -1 [:db_insert_placeholder_23] => 1676475738.847 [:db_insert_placeholder_24] => [:db_insert_placeholder_25] => 0 [:db_insert_placeholder_26] => b:0; [:db_insert_placeholder_27] => 1 [:db_insert_placeholder_28] => core.base_field_override.paragraph.related_sidebar_advertisement.type [:db_insert_placeholder_29] => -1 [:db_insert_placeholder_30] => 1676475738.847 [:db_insert_placeholder_31] => [:db_insert_placeholder_32] => 0 [:db_insert_placeholder_33] => b:0; [:db_insert_placeholder_34] => 1 [:db_insert_placeholder_35] => core.base_field_override.paragraph.related_sidebar_advertisement.status [:db_insert_placeholder_36] => -1 [:db_insert_placeholder_37] => 1676475738.847 [:db_insert_placeholder_38] => [:db_insert_placeholder_39] => 0 [:db_insert_placeholder_40] => b:0; [:db_insert_placeholder_41] => 1 [:db_insert_placeholder_42] => core.base_field_override.paragraph.related_sidebar_advertisement.created [:db_insert_placeholder_43] => -1 [:db_insert_placeholder_44] => 1676475738.847 [:db_insert_placeholder_45] => [:db_insert_placeholder_46] => 0 [:db_insert_placeholder_47] => b:0; [:db_insert_placeholder_48] => 1 [:db_insert_placeholder_49] => core.base_field_override.paragraph.related_sidebar_advertisement.parent_id [:db_insert_placeholder_50] => -1 [:db_insert_placeholder_51] => 1676475738.847 [:db_insert_placeholder_52] => [:db_insert_placeholder_53] => 0 [:db_insert_placeholder_54] => b:0; [:db_insert_placeholder_55] => 1 [:db_insert_placeholder_56] => core.base_field_override.paragraph.related_sidebar_advertisement.parent_type [:db_insert_placeholder_57] => -1 [:db_insert_placeholder_58] => 1676475738.847 [:db_insert_placeholder_59] => [:db_insert_placeholder_60] => 0 [:db_insert_placeholder_61] => b:0; [:db_insert_placeholder_62] => 1 [:db_insert_placeholder_63] => core.base_field_override.paragraph.related_sidebar_advertisement.parent_field_name [:db_insert_placeholder_64] => -1 [:db_insert_placeholder_65] => 1676475738.847 [:db_insert_placeholder_66] => [:db_insert_placeholder_67] => 0 [:db_insert_placeholder_68] => b:0; [:db_insert_placeholder_69] => 1 [:db_insert_placeholder_70] => core.base_field_override.paragraph.related_sidebar_advertisement.behavior_settings [:db_insert_placeholder_71] => -1 [:db_insert_placeholder_72] => 1676475738.847 [:db_insert_placeholder_73] => [:db_insert_placeholder_74] => 0 [:db_insert_placeholder_75] => b:0; [:db_insert_placeholder_76] => 1 [:db_insert_placeholder_77] => core.base_field_override.paragraph.related_sidebar_advertisement.default_langcode [:db_insert_placeholder_78] => -1 [:db_insert_placeholder_79] => 1676475738.847 [:db_insert_placeholder_80] => [:db_insert_placeholder_81] => 0 [:db_insert_placeholder_82] => b:0; [:db_insert_placeholder_83] => 1 [:db_insert_placeholder_84] => core.base_field_override.paragraph.related_sidebar_advertisement.revision_default [:db_insert_placeholder_85] => -1 [:db_insert_placeholder_86] => 1676475738.847 [:db_insert_placeholder_87] => [:db_insert_placeholder_88] => 0 [:db_insert_placeholder_89] => b:0; [:db_insert_placeholder_90] => 1 [:db_insert_placeholder_91] => core.base_field_override.paragraph.related_sidebar_advertisement.revision_translation_affected [:db_insert_placeholder_92] => -1 [:db_insert_placeholder_93] => 1676475738.847 [:db_insert_placeholder_94] => [:db_insert_placeholder_95] => 0 [:db_insert_placeholder_96] => b:0; [:db_insert_placeholder_97] => 1 ) in Drupal\Core\Cache\DatabaseBackend->doSetMultiple() (line 273 of /code/web/core/lib/Drupal/Core/Cache/DatabaseBackend.php).
PHP: 8.0
DB: 10.4.25-MariaDB-log
Core: 9.5.3
Schema: 4.2.6- 🇬🇧United Kingdom jacobupal Leeds
I've had this problem too (in 10.1), which is pretty concerning on a live site... it results in search results pages just filling up with a dump of content as plain text for pages and pages... all is fixed when I clear the cache... but if I'm not around to do that it's pretty catastrophic.
I thought we fixed it by uninstalling 'Search 404' which I presumed was making more requests than some part of the system could handle. Our hosting provider also increased some of the upper limits which we presumed might have led to this.
All seemed well for two weeks or so, but now it just happened again.
It seems like the problem is somewhere on the server, but what worries me is that it fails in such a weird way... if it failed with with an understandable error that'd be better than this. I'm guessing the dumped content is just the contents of the index, and so won't contain any sensitive information but it doesn't look great. Thank you for your help!
- 🇬🇧United Kingdom jacobupal Leeds
I didn't mention that this was using Database Search.
I misunderstood, until recently, what the risks of using Database Search on a production site would be, I thought it'd just run slower than some of the alternatives, but I feel like this issue with the index cache going wonky which seems to be happening when server resource limits are hit is a bit more severe than that, even if a result of that ignorance on my part.
We're looking into Solr anyhoo.
- Status changed to Active
8 months ago 3:43pm 18 April 2024 - Status changed to Postponed: needs info
8 months ago 7:53am 21 April 2024 - 🇦🇹Austria drunken monkey Vienna, Austria
Sorry, still not enough information for me to do anything. If I can’t reproduce it, there is no failing test, no stack trace or other detailed technical analysis, then I can only guess at the root cause. Since the error occurs when Core is writing to the config cache, it is still even unclear if this problem is really inside this module, or if it’s a bug in Core.
Is the exception also thrown inDrupal\Core\Cache\DatabaseBackend->doSetMultiple()
in your case?That a dump of the search results (I guess?) is displayed on the search results page seems like a completely separate issue, as none of the others mentioned that. Please create a new issue for that. However, I don’t think I heard about anything like that before, so it seems pretty specific to your setup. Maybe you just need to disable/restrict error reporting? In any case, without more detailed technical information I won’t be able to help with this problem, either, I’m afraid.
- 🇮🇳India mpmano
We are facing the same issue with solr integration as well.
Drupal\Core\Database\DatabaseExceptionWrapper while computing Views data for index Default node index: SQLSTATE[40001]: Serialization failure: 1213 Deadlock found when trying to get lock; try restarting transaction:
Case: while doing Clear the cache & search process simultaneously. The corresponding views indexed fields are also showing as broken links.
System:
Drupal : 10.1.4
PHP: 8.1.28
DB: MySql 8.0.36 - 🇫🇷France nicolas bouteille
Hello,
This error is pretty new to us, but we've experienced it three times in the last month.
Drupal\Core\Database\DatabaseExceptionWrapper while computing Views data for index Leçon: SQLSTATE[40001]: Serialization failure: 1213 Deadlock found when trying to get lock; try restarting transaction: INSERT INTO "cache_config"
It happened during our last two deployment process during the final cache rebuild, and it also happened this morning during our weekly full cache rebuild.
So I agree this definitely seems to be due to cache rebuilding at the same time than Search API is "computing Views data for index".
What I don't understand is why Search API when "computing Views data for index" would try to insert data into cache_config table, especially data regarding paragraphs fields…I can also confirm that the error was triggered by DatabaseBackend->doSetMultiple()
I will provide the full stack trace below.For the record, the search_api_cron is scheduled to run every 15 minutes on our website. This morning the cron ran at 7:30 which is the exact same time the full cache rebuild was triggered. So at first I figured the error could happen when search_api_cron runs while a cache rebuild is in progress.
However, our server is responsible for triggering cron runs every 5 minutes, and we disable drush cron during the whole deployment process. So search_api_cron should not have ran while our final cache rebuild but right after because the very next move is to unlock cron runs. So maybe the problem can happen when search_api_cron is called in the few milliseconds right after the cache rebuild is done…
But there is another clue that makes me think that the error is not necessarily caused by search_api_cron : the request_uri that logged the error is https://www.MY_WEBSITE.com/formation/3d/cinema-4d/cinema-4d-2023-les-mat... which is a basic lesson page
If I am not mistaken, if the error had happened during cron run, the request_uri would have been different isn't it?I need to spend more time to understand what "computing Views data for index" means, and what action this relates to, so in which situation this error message can happen… I don't know yet if it means Search API is reindexing the index, or simply fetching data in order to deliver it to views…
But the biggest and scariest question that remains is: what's the link between Search API "computing Views data for index" and the insertion of paragraph field data inside cache_config…
For the record, after this Deadlock found error in cache_config happened, we started to have a lot of the following error:
Drupal\Component\Plugin\Exception\PluginNotFoundException: The "" entity type does not exist. in Drupal\Core\Entity\EntityTypeManager->getDefinition() (line 139 of web/core/lib/Drupal/Core/Entity/EntityTypeManager.php).
Which sounded like the cache_config was not correctly filled. So we rebuilt the cache again and the error was gone.
So it seems Search API process stops the cache rebuild process, and we end up with a bad cache_config table.Last but not least, it is fair to say that in the last month, we've considerably increased the data stored inside each node "Lesson". The only index we've created with Search API is out Lesson index. It has around 50 000 lessons. However, these new fields and data that we've recently added to a lot of our Lessons, we have not added it yet to the indexed fields...
Stack trace below:
Drupal\Core\Database\DatabaseExceptionWrapper while computing Views data for index Leçon: SQLSTATE[40001]: Serialization failure: 1213 Deadlock found when trying to get lock; try restarting transaction: INSERT INTO "cache_config" ("cid", "expire", "created", "tags", "checksum", "data", "serialized") VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3, :db_insert_placeholder_4, :db_insert_placeholder_5, :db_insert_placeholder_6), (:db_insert_placeholder_7, :db_insert_placeholder_8, :db_insert_placeholder_9, :db_insert_placeholder_10, :db_insert_placeholder_11, :db_insert_placeholder_12, :db_insert_placeholder_13), (:db_insert_placeholder_14, :db_insert_placeholder_15, :db_insert_placeholder_16, :db_insert_placeholder_17, :db_insert_placeholder_18, :db_insert_placeholder_19, :db_insert_placeholder_20), (:db_insert_placeholder_21, :db_insert_placeholder_22, :db_insert_placeholder_23, :db_insert_placeholder_24, :db_insert_placeholder_25, :db_insert_placeholder_26, :db_insert_placeholder_27), (:db_insert_placeholder_28, :db_insert_placeholder_29, :db_insert_placeholder_30, :db_insert_placeholder_31, :db_insert_placeholder_32, :db_insert_placeholder_33, :db_insert_placeholder_34), (:db_insert_placeholder_35, :db_insert_placeholder_36, :db_insert_placeholder_37, :db_insert_placeholder_38, :db_insert_placeholder_39, :db_insert_placeholder_40, :db_insert_placeholder_41), (:db_insert_placeholder_42, :db_insert_placeholder_43, :db_insert_placeholder_44, :db_insert_placeholder_45, :db_insert_placeholder_46, :db_insert_placeholder_47, :db_insert_placeholder_48), (:db_insert_placeholder_49, :db_insert_placeholder_50, :db_insert_placeholder_51, :db_insert_placeholder_52, :db_insert_placeholder_53, :db_insert_placeholder_54, :db_insert_placeholder_55), (:db_insert_placeholder_56, :db_insert_placeholder_57, :db_insert_placeholder_58, :db_insert_placeholder_59, :db_insert_placeholder_60, :db_insert_placeholder_61, :db_insert_placeholder_62), (:db_insert_placeholder_63, :db_insert_placeholder_64, :db_insert_placeholder_65, :db_insert_placeholder_66, :db_insert_placeholder_67, :db_insert_placeholder_68, :db_insert_placeholder_69), (:db_insert_placeholder_70, :db_insert_placeholder_71, :db_insert_placeholder_72, :db_insert_placeholder_73, :db_insert_placeholder_74, :db_insert_placeholder_75, :db_insert_placeholder_76), (:db_insert_placeholder_77, :db_insert_placeholder_78, :db_insert_placeholder_79, :db_insert_placeholder_80, :db_insert_placeholder_81, :db_insert_placeholder_82, :db_insert_placeholder_83), (:db_insert_placeholder_84, :db_insert_placeholder_85, :db_insert_placeholder_86, :db_insert_placeholder_87, :db_insert_placeholder_88, :db_insert_placeholder_89, :db_insert_placeholder_90), (:db_insert_placeholder_91, :db_insert_placeholder_92, :db_insert_placeholder_93, :db_insert_placeholder_94, :db_insert_placeholder_95, :db_insert_placeholder_96, :db_insert_placeholder_97) ON DUPLICATE KEY UPDATE "cid" = VALUES("cid"), "expire" = VALUES("expire"), "created" = VALUES("created"), "tags" = VALUES("tags"), "checksum" = VALUES("checksum"), "data" = VALUES("data"), "serialized" = VALUES("serialized"); Array ( [:db_insert_placeholder_0] => core.base_field_override.paragraph.discover_catalog.id [:db_insert_placeholder_1] => -1 [:db_insert_placeholder_2] => 1719811809.205 [:db_insert_placeholder_3] => [:db_insert_placeholder_4] => 0 [:db_insert_placeholder_5] => b:0; [:db_insert_placeholder_6] => 1 [:db_insert_placeholder_7] => core.base_field_override.paragraph.discover_catalog.uuid [:db_insert_placeholder_8] => -1 [:db_insert_placeholder_9] => 1719811809.205 [:db_insert_placeholder_10] => [:db_insert_placeholder_11] => 0 [:db_insert_placeholder_12] => b:0; [:db_insert_placeholder_13] => 1 [:db_insert_placeholder_14] => core.base_field_override.paragraph.discover_catalog.revision_id [:db_insert_placeholder_15] => -1 [:db_insert_placeholder_16] => 1719811809.205 [:db_insert_placeholder_17] => [:db_insert_placeholder_18] => 0 [:db_insert_placeholder_19] => b:0; [:db_insert_placeholder_20] => 1 [:db_insert_placeholder_21] => core.base_field_override.paragraph.discover_catalog.langcode [:db_insert_placeholder_22] => -1 [:db_insert_placeholder_23] => 1719811809.205 [:db_insert_placeholder_24] => [:db_insert_placeholder_25] => 0 [:db_insert_placeholder_26] => b:0; [:db_insert_placeholder_27] => 1 [:db_insert_placeholder_28] => core.base_field_override.paragraph.discover_catalog.type [:db_insert_placeholder_29] => -1 [:db_insert_placeholder_30] => 1719811809.205 [:db_insert_placeholder_31] => [:db_insert_placeholder_32] => 0 [:db_insert_placeholder_33] => b:0; [:db_insert_placeholder_34] => 1 [:db_insert_placeholder_35] => core.base_field_override.paragraph.discover_catalog.status [:db_insert_placeholder_36] => -1 [:db_insert_placeholder_37] => 1719811809.205 [:db_insert_placeholder_38] => [:db_insert_placeholder_39] => 0 [:db_insert_placeholder_40] => b:0; [:db_insert_placeholder_41] => 1 [:db_insert_placeholder_42] => core.base_field_override.paragraph.discover_catalog.created [:db_insert_placeholder_43] => -1 [:db_insert_placeholder_44] => 1719811809.205 [:db_insert_placeholder_45] => [:db_insert_placeholder_46] => 0 [:db_insert_placeholder_47] => b:0; [:db_insert_placeholder_48] => 1 [:db_insert_placeholder_49] => core.base_field_override.paragraph.discover_catalog.parent_id [:db_insert_placeholder_50] => -1 [:db_insert_placeholder_51] => 1719811809.205 [:db_insert_placeholder_52] => [:db_insert_placeholder_53] => 0 [:db_insert_placeholder_54] => b:0; [:db_insert_placeholder_55] => 1 [:db_insert_placeholder_56] => core.base_field_override.paragraph.discover_catalog.parent_type [:db_insert_placeholder_57] => -1 [:db_insert_placeholder_58] => 1719811809.205 [:db_insert_placeholder_59] => [:db_insert_placeholder_60] => 0 [:db_insert_placeholder_61] => b:0; [:db_insert_placeholder_62] => 1 [:db_insert_placeholder_63] => core.base_field_override.paragraph.discover_catalog.parent_field_name [:db_insert_placeholder_64] => -1 [:db_insert_placeholder_65] => 1719811809.205 [:db_insert_placeholder_66] => [:db_insert_placeholder_67] => 0 [:db_insert_placeholder_68] => b:0; [:db_insert_placeholder_69] => 1 [:db_insert_placeholder_70] => core.base_field_override.paragraph.discover_catalog.behavior_settings [:db_insert_placeholder_71] => -1 [:db_insert_placeholder_72] => 1719811809.205 [:db_insert_placeholder_73] => [:db_insert_placeholder_74] => 0 [:db_insert_placeholder_75] => b:0; [:db_insert_placeholder_76] => 1 [:db_insert_placeholder_77] => core.base_field_override.paragraph.discover_catalog.default_langcode [:db_insert_placeholder_78] => -1 [:db_insert_placeholder_79] => 1719811809.205 [:db_insert_placeholder_80] => [:db_insert_placeholder_81] => 0 [:db_insert_placeholder_82] => b:0; [:db_insert_placeholder_83] => 1 [:db_insert_placeholder_84] => core.base_field_override.paragraph.discover_catalog.revision_default [:db_insert_placeholder_85] => -1 [:db_insert_placeholder_86] => 1719811809.205 [:db_insert_placeholder_87] => [:db_insert_placeholder_88] => 0 [:db_insert_placeholder_89] => b:0; [:db_insert_placeholder_90] => 1 [:db_insert_placeholder_91] => core.base_field_override.paragraph.discover_catalog.revision_translation_affected [:db_insert_placeholder_92] => -1 [:db_insert_placeholder_93] => 1719811809.205 [:db_insert_placeholder_94] => [:db_insert_placeholder_95] => 0 [:db_insert_placeholder_96] => b:0; [:db_insert_placeholder_97] => 1 ) in Drupal\Core\Cache\DatabaseBackend->doSetMultiple() (line 283 of /PATH_TO_PROJECT/web/core/lib/Drupal/Core/Cache/DatabaseBackend.php). Détails Array ( [%type] => Drupal\Core\Database\DatabaseExceptionWrapper [@message] => SQLSTATE[40001]: Serialization failure: 1213 Deadlock found when trying to get lock; try restarting transaction: INSERT INTO "cache_config" ("cid", "expire", "created", "tags", "checksum", "data", "serialized") VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3, :db_insert_placeholder_4, :db_insert_placeholder_5, :db_insert_placeholder_6), (:db_insert_placeholder_7, :db_insert_placeholder_8, :db_insert_placeholder_9, :db_insert_placeholder_10, :db_insert_placeholder_11, :db_insert_placeholder_12, :db_insert_placeholder_13), (:db_insert_placeholder_14, :db_insert_placeholder_15, :db_insert_placeholder_16, :db_insert_placeholder_17, :db_insert_placeholder_18, :db_insert_placeholder_19, :db_insert_placeholder_20), (:db_insert_placeholder_21, :db_insert_placeholder_22, :db_insert_placeholder_23, :db_insert_placeholder_24, :db_insert_placeholder_25, :db_insert_placeholder_26, :db_insert_placeholder_27), (:db_insert_placeholder_28, :db_insert_placeholder_29, :db_insert_placeholder_30, :db_insert_placeholder_31, :db_insert_placeholder_32, :db_insert_placeholder_33, :db_insert_placeholder_34), (:db_insert_placeholder_35, :db_insert_placeholder_36, :db_insert_placeholder_37, :db_insert_placeholder_38, :db_insert_placeholder_39, :db_insert_placeholder_40, :db_insert_placeholder_41), (:db_insert_placeholder_42, :db_insert_placeholder_43, :db_insert_placeholder_44, :db_insert_placeholder_45, :db_insert_placeholder_46, :db_insert_placeholder_47, :db_insert_placeholder_48), (:db_insert_placeholder_49, :db_insert_placeholder_50, :db_insert_placeholder_51, :db_insert_placeholder_52, :db_insert_placeholder_53, :db_insert_placeholder_54, :db_insert_placeholder_55), (:db_insert_placeholder_56, :db_insert_placeholder_57, :db_insert_placeholder_58, :db_insert_placeholder_59, :db_insert_placeholder_60, :db_insert_placeholder_61, :db_insert_placeholder_62), (:db_insert_placeholder_63, :db_insert_placeholder_64, :db_insert_placeholder_65, :db_insert_placeholder_66, :db_insert_placeholder_67, :db_insert_placeholder_68, :db_insert_placeholder_69), (:db_insert_placeholder_70, :db_insert_placeholder_71, :db_insert_placeholder_72, :db_insert_placeholder_73, :db_insert_placeholder_74, :db_insert_placeholder_75, :db_insert_placeholder_76), (:db_insert_placeholder_77, :db_insert_placeholder_78, :db_insert_placeholder_79, :db_insert_placeholder_80, :db_insert_placeholder_81, :db_insert_placeholder_82, :db_insert_placeholder_83), (:db_insert_placeholder_84, :db_insert_placeholder_85, :db_insert_placeholder_86, :db_insert_placeholder_87, :db_insert_placeholder_88, :db_insert_placeholder_89, :db_insert_placeholder_90), (:db_insert_placeholder_91, :db_insert_placeholder_92, :db_insert_placeholder_93, :db_insert_placeholder_94, :db_insert_placeholder_95, :db_insert_placeholder_96, :db_insert_placeholder_97) ON DUPLICATE KEY UPDATE "cid" = VALUES("cid"), "expire" = VALUES("expire"), "created" = VALUES("created"), "tags" = VALUES("tags"), "checksum" = VALUES("checksum"), "data" = VALUES("data"), "serialized" = VALUES("serialized"); Array ( [:db_insert_placeholder_0] => core.base_field_override.paragraph.discover_catalog.id [:db_insert_placeholder_1] => -1 [:db_insert_placeholder_2] => 1719811809.205 [:db_insert_placeholder_3] => [:db_insert_placeholder_4] => 0 [:db_insert_placeholder_5] => b:0; [:db_insert_placeholder_6] => 1 [:db_insert_placeholder_7] => core.base_field_override.paragraph.discover_catalog.uuid [:db_insert_placeholder_8] => -1 [:db_insert_placeholder_9] => 1719811809.205 [:db_insert_placeholder_10] => [:db_insert_placeholder_11] => 0 [:db_insert_placeholder_12] => b:0; [:db_insert_placeholder_13] => 1 [:db_insert_placeholder_14] => core.base_field_override.paragraph.discover_catalog.revision_id [:db_insert_placeholder_15] => -1 [:db_insert_placeholder_16] => 1719811809.205 [:db_insert_placeholder_17] => [:db_insert_placeholder_18] => 0 [:db_insert_placeholder_19] => b:0; [:db_insert_placeholder_20] => 1 [:db_insert_placeholder_21] => core.base_field_override.paragraph.discover_catalog.langcode [:db_insert_placeholder_22] => -1 [:db_insert_placeholder_23] => 1719811809.205 [:db_insert_placeholder_24] => [:db_insert_placeholder_25] => 0 [:db_insert_placeholder_26] => b:0; [:db_insert_placeholder_27] => 1 [:db_insert_placeholder_28] => core.base_field_override.paragraph.discover_catalog.type [:db_insert_placeholder_29] => -1 [:db_insert_placeholder_30] => 1719811809.205 [:db_insert_placeholder_31] => [:db_insert_placeholder_32] => 0 [:db_insert_placeholder_33] => b:0; [:db_insert_placeholder_34] => 1 [:db_insert_placeholder_35] => core.base_field_override.paragraph.discover_catalog.status [:db_insert_placeholder_36] => -1 [:db_insert_placeholder_37] => 1719811809.205 [:db_insert_placeholder_38] => [:db_insert_placeholder_39] => 0 [:db_insert_placeholder_40] => b:0; [:db_insert_placeholder_41] => 1 [:db_insert_placeholder_42] => core.base_field_override.paragraph.discover_catalog.created [:db_insert_placeholder_43] => -1 [:db_insert_placeholder_44] => 1719811809.205 [:db_insert_placeholder_45] => [:db_insert_placeholder_46] => 0 [:db_insert_placeholder_47] => b:0; [:db_insert_placeholder_48] => 1 [:db_insert_placeholder_49] => core.base_field_override.paragraph.discover_catalog.parent_id [:db_insert_placeholder_50] => -1 [:db_insert_placeholder_51] => 1719811809.205 [:db_insert_placeholder_52] => [:db_insert_placeholder_53] => 0 [:db_insert_placeholder_54] => b:0; [:db_insert_placeholder_55] => 1 [:db_insert_placeholder_56] => core.base_field_override.paragraph.discover_catalog.parent_type [:db_insert_placeholder_57] => -1 [:db_insert_placeholder_58] => 1719811809.205 [:db_insert_placeholder_59] => [:db_insert_placeholder_60] => 0 [:db_insert_placeholder_61] => b:0; [:db_insert_placeholder_62] => 1 [:db_insert_placeholder_63] => core.base_field_override.paragraph.discover_catalog.parent_field_name [:db_insert_placeholder_64] => -1 [:db_insert_placeholder_65] => 1719811809.205 [:db_insert_placeholder_66] => [:db_insert_placeholder_67] => 0 [:db_insert_placeholder_68] => b:0; [:db_insert_placeholder_69] => 1 [:db_insert_placeholder_70] => core.base_field_override.paragraph.discover_catalog.behavior_settings [:db_insert_placeholder_71] => -1 [:db_insert_placeholder_72] => 1719811809.205 [:db_insert_placeholder_73] => [:db_insert_placeholder_74] => 0 [:db_insert_placeholder_75] => b:0; [:db_insert_placeholder_76] => 1 [:db_insert_placeholder_77] => core.base_field_override.paragraph.discover_catalog.default_langcode [:db_insert_placeholder_78] => -1 [:db_insert_placeholder_79] => 1719811809.205 [:db_insert_placeholder_80] => [:db_insert_placeholder_81] => 0 [:db_insert_placeholder_82] => b:0; [:db_insert_placeholder_83] => 1 [:db_insert_placeholder_84] => core.base_field_override.paragraph.discover_catalog.revision_default [:db_insert_placeholder_85] => -1 [:db_insert_placeholder_86] => 1719811809.205 [:db_insert_placeholder_87] => [:db_insert_placeholder_88] => 0 [:db_insert_placeholder_89] => b:0; [:db_insert_placeholder_90] => 1 [:db_insert_placeholder_91] => core.base_field_override.paragraph.discover_catalog.revision_translation_affected [:db_insert_placeholder_92] => -1 [:db_insert_placeholder_93] => 1719811809.205 [:db_insert_placeholder_94] => [:db_insert_placeholder_95] => 0 [:db_insert_placeholder_96] => b:0; [:db_insert_placeholder_97] => 1 ) [%function] => Drupal\Core\Cache\DatabaseBackend->doSetMultiple() [%file] => /PATH_TO_PROJECT/web/core/lib/Drupal/Core/Cache/DatabaseBackend.php [%line] => 283 [severity_level] => 3 [@backtrace_string] => #0 /PATH_TO_PROJECT/web/core/lib/Drupal/Core/Database/Query/Upsert.php(119): Drupal\mysql\Driver\Database\mysql\ExceptionHandler->handleExecutionException() #1 /PATH_TO_PROJECT/web/core/lib/Drupal/Core/Cache/DatabaseBackend.php(283): Drupal\Core\Database\Query\Upsert->execute() #2 /PATH_TO_PROJECT/web/core/lib/Drupal/Core/Cache/DatabaseBackend.php(198): Drupal\Core\Cache\DatabaseBackend->doSetMultiple() #3 /PATH_TO_PROJECT/web/core/lib/Drupal/Core/Config/CachedStorage.php(105): Drupal\Core\Cache\DatabaseBackend->setMultiple() #4 /PATH_TO_PROJECT/web/core/lib/Drupal/Core/Config/ConfigFactory.php(165): Drupal\Core\Config\CachedStorage->readMultiple() #5 /PATH_TO_PROJECT/web/core/lib/Drupal/Core/Config/ConfigFactory.php(136): Drupal\Core\Config\ConfigFactory->doLoadMultiple() #6 /PATH_TO_PROJECT/web/core/lib/Drupal/Core/Config/Entity/ConfigEntityStorage.php(181): Drupal\Core\Config\ConfigFactory->loadMultiple() #7 /PATH_TO_PROJECT/web/core/lib/Drupal/Core/Entity/EntityStorageBase.php(312): Drupal\Core\Config\Entity\ConfigEntityStorage->doLoadMultiple() #8 /PATH_TO_PROJECT/web/core/lib/Drupal/Core/Entity/EntityFieldManager.php(395): Drupal\Core\Entity\EntityStorageBase->loadMultiple() #9 /PATH_TO_PROJECT/web/core/lib/Drupal/Core/Entity/EntityFieldManager.php(353): Drupal\Core\Entity\EntityFieldManager->buildBundleFieldDefinitions() #10 /PATH_TO_PROJECT/web/modules/contrib/search_api/src/Plugin/search_api/processor/ReverseEntityReferences.php(383): Drupal\Core\Entity\EntityFieldManager->getFieldDefinitions() #11 /PATH_TO_PROJECT/web/modules/contrib/search_api/src/Plugin/search_api/processor/ReverseEntityReferences.php(235): Drupal\search_api\Plugin\search_api\processor\ReverseEntityReferences->getEntityReferences() #12 /PATH_TO_PROJECT/web/modules/contrib/search_api/src/Entity/Index.php(845): Drupal\search_api\Plugin\search_api\processor\ReverseEntityReferences->getPropertyDefinitions() #13 /PATH_TO_PROJECT/web/modules/contrib/search_api/src/Item/Field.php(475): Drupal\search_api\Entity\Index->getPropertyDefinitions() #14 /PATH_TO_PROJECT/web/modules/contrib/search_api/search_api.views.inc(206): Drupal\search_api\Item\Field->getDataDefinition() #15 /PATH_TO_PROJECT/web/modules/contrib/search_api/search_api.views.inc(63): _search_api_views_get_handlers() #16 /PATH_TO_PROJECT/web/core/modules/views/src/ViewsData.php(228): search_api_views_data() #17 /PATH_TO_PROJECT/web/core/lib/Drupal/Core/Extension/ModuleHandler.php(388): Drupal\views\ViewsData->Drupal\views\{closure}() #18 /PATH_TO_PROJECT/web/core/modules/views/src/ViewsData.php(236): Drupal\Core\Extension\ModuleHandler->invokeAllWith() #19 /PATH_TO_PROJECT/web/core/modules/views/src/ViewsData.php(151): Drupal\views\ViewsData->getData() #20 /PATH_TO_PROJECT/web/core/modules/views/src/Plugin/Derivative/ViewsEntityRow.php(94): Drupal\views\ViewsData->get() #21 /PATH_TO_PROJECT/web/core/lib/Drupal/Component/Plugin/Discovery/DerivativeDiscoveryDecorator.php(101): Drupal\views\Plugin\Derivative\ViewsEntityRow->getDerivativeDefinitions() #22 /PATH_TO_PROJECT/web/core/lib/Drupal/Component/Plugin/Discovery/DerivativeDiscoveryDecorator.php(87): Drupal\Component\Plugin\Discovery\DerivativeDiscoveryDecorator->getDerivatives() #23 /PATH_TO_PROJECT/web/core/lib/Drupal/Core/Plugin/DefaultPluginManager.php(323): Drupal\Component\Plugin\Discovery\DerivativeDiscoveryDecorator->getDefinitions() #24 /PATH_TO_PROJECT/web/core/lib/Drupal/Core/Plugin/DefaultPluginManager.php(205): Drupal\Core\Plugin\DefaultPluginManager->findDefinitions() #25 /PATH_TO_PROJECT/web/core/modules/views/views.module(146): Drupal\Core\Plugin\DefaultPluginManager->getDefinitions() #26 /PATH_TO_PROJECT/web/core/lib/Drupal/Core/Theme/Registry.php(479): views_theme() #27 /PATH_TO_PROJECT/web/core/lib/Drupal/Core/Theme/Registry.php(372): Drupal\Core\Theme\Registry->processExtension() #28 /PATH_TO_PROJECT/web/core/lib/Drupal/Core/Extension/ModuleHandler.php(388): Drupal\Core\Theme\Registry->Drupal\Core\Theme\{closure}() #29 /PATH_TO_PROJECT/web/core/lib/Drupal/Core/Theme/Registry.php(373): Drupal\Core\Extension\ModuleHandler->invokeAllWith() #30 /PATH_TO_PROJECT/web/core/lib/Drupal/Core/Theme/Registry.php(255): Drupal\Core\Theme\Registry->build() #31 /PATH_TO_PROJECT/web/core/lib/Drupal/Core/Utility/ThemeRegistry.php(88): Drupal\Core\Theme\Registry->get() #32 /PATH_TO_PROJECT/web/core/lib/Drupal/Core/Utility/ThemeRegistry.php(69): Drupal\Core\Utility\ThemeRegistry->initializeRegistry() #33 /PATH_TO_PROJECT/web/core/lib/Drupal/Core/Theme/Registry.php(291): Drupal\Core\Utility\ThemeRegistry->__construct() #34 /PATH_TO_PROJECT/web/core/lib/Drupal/Core/Entity/EntityViewBuilder.php(193): Drupal\Core\Theme\Registry->getRuntime() #35 /PATH_TO_PROJECT/web/core/lib/Drupal/Core/Entity/EntityViewBuilder.php(157): Drupal\Core\Entity\EntityViewBuilder->getBuildDefaults() #36 /PATH_TO_PROJECT/web/core/lib/Drupal/Core/Entity/EntityViewBuilder.php(123): Drupal\Core\Entity\EntityViewBuilder->viewMultiple() #37 /PATH_TO_PROJECT/web/core/lib/Drupal/Core/Entity/Controller/EntityViewController.php(134): Drupal\Core\Entity\EntityViewBuilder->view() #38 [internal function]: Drupal\Core\Entity\Controller\EntityViewController->view() #39 /PATH_TO_PROJECT/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(123): call_user_func_array() #40 /PATH_TO_PROJECT/web/core/lib/Drupal/Core/Render/Renderer.php(627): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() #41 /PATH_TO_PROJECT/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(124): Drupal\Core\Render\Renderer->executeInRenderContext() #42 /PATH_TO_PROJECT/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(97): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext() #43 /PATH_TO_PROJECT/vendor/symfony/http-kernel/HttpKernel.php(181): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() #44 /PATH_TO_PROJECT/vendor/symfony/http-kernel/HttpKernel.php(76): Symfony\Component\HttpKernel\HttpKernel->handleRaw() #45 /PATH_TO_PROJECT/web/core/lib/Drupal/Core/StackMiddleware/Session.php(58): Symfony\Component\HttpKernel\HttpKernel->handle() #46 /PATH_TO_PROJECT/web/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(48): Drupal\Core\StackMiddleware\Session->handle() #47 /PATH_TO_PROJECT/web/core/lib/Drupal/Core/StackMiddleware/ContentLength.php(28): Drupal\Core\StackMiddleware\KernelPreHandle->handle() #48 /PATH_TO_PROJECT/web/core/modules/big_pipe/src/StackMiddleware/ContentLength.php(32): Drupal\Core\StackMiddleware\ContentLength->handle() #49 /PATH_TO_PROJECT/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(191): Drupal\big_pipe\StackMiddleware\ContentLength->handle() #50 /PATH_TO_PROJECT/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(128): Drupal\page_cache\StackMiddleware\PageCache->fetch() #51 /PATH_TO_PROJECT/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(82): Drupal\page_cache\StackMiddleware\PageCache->lookup() #52 /PATH_TO_PROJECT/web/core/modules/ban/src/BanMiddleware.php(50): Drupal\page_cache\StackMiddleware\PageCache->handle() #53 /PATH_TO_PROJECT/web/modules/custom/MY_CUSTOM_MODULE/src/BanMiddleware.php(97): Drupal\ban\BanMiddleware->handle() #54 /PATH_TO_PROJECT/web/modules/contrib/shield/src/ShieldMiddleware.php(270): Drupal\MY_CUSTOM_MODULE\BanMiddleware->handle() #55 /PATH_TO_PROJECT/web/modules/contrib/shield/src/ShieldMiddleware.php(137): Drupal\shield\ShieldMiddleware->bypass() #56 /PATH_TO_PROJECT/web/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(48): Drupal\shield\ShieldMiddleware->handle() #57 /PATH_TO_PROJECT/web/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(51): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle() #58 /PATH_TO_PROJECT/web/core/lib/Drupal/Core/StackMiddleware/AjaxPageState.php(36): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle() #59 /PATH_TO_PROJECT/web/core/lib/Drupal/Core/StackMiddleware/StackedHttpKernel.php(51): Drupal\Core\StackMiddleware\AjaxPageState->handle() #60 /PATH_TO_PROJECT/web/core/lib/Drupal/Core/DrupalKernel.php(704): Drupal\Core\StackMiddleware\StackedHttpKernel->handle() #61 /PATH_TO_PROJECT/web/index.php(19): Drupal\Core\DrupalKernel->handle() #62 {main} [%index] => Leçon [channel] => search_api [link] => [uid] => 0 [request_uri] => https://www.MY_WEBSITE.com/formation/3d/cinema-4d/cinema-4d-2023-les-materiaux [referer] => [ip] => 40.77.167.254 [timestamp] => 1719811809 )
- Status changed to Active
4 months ago 9:55am 27 August 2024 - 🇫🇷France nicolas bouteille
Hi,
I'd like to reopen this issue in order not to pollute 🐛 Consider to remove exception handling from search_api_views_data Needs review
We're still facing this issue when rebuilding cache + someone accesses a page that triggers a call to search_api_views_data().
Today we even faced it with the site under maintenance which makes it really problematic for us.
I'd like to find out how I can prevent this from happening.From what I understand, the error message "while computing Views data for index" can only be thrown by search_api_views_data().
I also know from the system logs that the error thrown by search_api_views_data() happens when "someone accesses a page" because I have the uri and referer.
In order to prevent this from happening, there are two things I need to understand better:
1/ in which scenario can search_api_views_data() be called? I have tried to debug this locally but for a given url, search_api_views_data() is never called unless the caches are being rebuilt.
2/ how come search_api_views_data() tries to write in cache_config table? Shouldn't the cache_config of search API be written only when we rebuild cache? This would solve the problem…Thank you for your enlightenment.
- 🇫🇷France nicolas bouteille
After digging a bit more:
It seems that Index::loadMultiple() in search_api_views_data() is responsible for writing into cache_config if the indexes are no longer in cache.
Also, it seems that search_api_views_data() (like all hook_views_data implementations) will only be called if both views_data:[language] and views_data:views:[language] entries are missing from table cache_default.
When the caches are being emptied, any visitor accessing a page will thus trigger search_api_views_data(), which will then try to write into cache_config because the indexes are missing from cache.
Drush cr will also call search_api_views_data() in its process.
Most probable scenario: drush cr gets here first, puts the lock on cache_config leading to the deadlock found error when search_api_views_data() gets executed by visitors requesting pages. This is no so bad since drush cr will eventually call search_api_views_data() anyway, so we could indeed not throw the exception.
Worst case scenario : a visitor triggers search_api_views_data() and puts a lock on cache_config preventing drush cr from rebuilding correctly the caches. This is bad and should be avoided.
Suggested solution:
I think we should only allow the execution of search_api_views_data() if triggered by drush cr or /admin/flush and stop its execution if triggered by a regular page request.Here is the custom code I will be adding right now to my project in order to do so. What do you think?
<?php if (php_sapi_name() === 'cli' && in_array('./vendor/bin/drush', $_SERVER['argv'])) { // case drush cr: do not block execution } elseif (\Drupal::routeMatch()->getRouteName() === 'admin_toolbar_tools.flush') { // case /admin/flush: do not block execution } else { // triggered by visitor requesting a page: stop execution to make sure no lock gets in the way of cache rebuilding return []; } ?>
- 🇫🇷France nicolas bouteille
I would like to suggest one more thing: if Index::loadMultiple is indeed the code responsible for writing in cache_config when the indexes are not in cache (because search_api_index are configuration entities and not content ones…) Then I think maybe we'd better not use loadMultiple to retrieve index data inside search_api_views_data() which is a hook that will be called when caches are rebuilt. More direct database requests would avoid lock conflicts here on cache_config.
That being said, I still believe our best bet here is to prevent the execution of search_api_views_data() unless it is being triggered by drush cr or admin/flush because even if the lock conflicts are avoided for cache_config, there could be new lock conflicts when multiple simultaneous calls to search_api_views_data() try to write the same data at the same place.
For the record, I now understand better why we are having these lock conflicts on our production website when we thought rebuilding cache under maintenance mode would prevent them from happening. We have light ajax calls triggered on our pages every 20s to store our student progress. Normally these ajax calls never trigger search_api_views_data() even if all cache tables are emptied.
However, I noticed that when the site is under maintenance and all caches are emptied, calling one of these ajax urls will trigger search_api_views_data() this time. Normally, search_api_views_data() should be triggered only once... but if multiple ajax calls are requested quite simultaneously on a production website with lots of visitors, they will all trigger search_api_views_data and generate multiple deadlock errors in the logs. This is what we faced during our last deployment. The code I suggested above should protect us from that in the future I hope. - 🇬🇧United Kingdom scott_euser
Hmmm if that's the case that its the views_data causing the issue, I would expect that 🐛 Views handler loading should respect configuration Needs review in core should solve the issue then.
- 🇦🇹Austria drunken monkey Vienna, Austria
Huh, I thought I’d replied to the latest comments already. Sorry.
Anyways, returning[]
fromsearch_api_views_data()
seems like it would remove all the Search API tables from views, breaking all search views on the site. You can’t tell Views “this is not a real result, just a placeholder” in the hook implementation, what you return will get cached and used until the next cache rebuild.Also, avoiding something as simple as a config entity load in
hook_views_data()
seems like it really shouldn’t be necessary. I’m sure there are lots of hook implementations that do this, if this really causes problems in some scenarios I’d say this would be a bug in Core.@scott_euser: Thanks for linking to that, seems like it’s worth a try. (Though it doesn’t seem like it’s completely the same problem.)
- 🇬🇪Georgia iamdroid
Hi folks, we have exactly the same issue as described in #16.
@nicolas bouteille have you eventually solved the issue for your project?
- 🇫🇷France nicolas bouteille
Well for now we're using the code I shared above, but first we're checking if we are currently rebuilding caches and our blocking code is only executed if we are indeed rebuilding caches. Because we are sure the rebuilding caches process will also rebuild search api indexes, it is ok to block regular pages from trying to do the exact same thing. It is actually necessary to block them during that specific period of time.
The way we are doing it so far is we check whether our index still exists or has been deleted from the cache.$our_index_in_cache = \Drupal::cache('config')->get('search_api.index.our_index'); if( ! $our_index_in_cache) { // if our index is not in cache it means we are currently rebuilding cache // so any regular page call in maintenance mode that could trigger this hook will simply return [] // only drush cr or admin_toolbar_tools.flush will be allowed to let the rest of the code execute }
So far this seems to be working well. We did not have errors during our last production deployment. But I am no expert and this is experimental stuff. I was hoping for some help and more robust code from maintainers, but it seems they don't share my conclusions so far.
This problem only occurs for high traffic websites with lots of data. It only happens because many people are visiting your website while you put it in maintenance mode. I don't know why but hook_views_data gets triggered by simple page calls when the maintenance mode is on. So if your rebuilding cache while in maintenance mode with many people visiting your site, you're gonna get lock conflicts because of loadMultiple. Also the more data needs to be written in your index cache, the more time the lock stays on, the more chances to have a lock conflict. It works both ways btw, the more data Drupal needs to write inside cache_config when rebuilding caches, the more chances search_api_views_data has be blocked by a lock on cache_config if it's called while caches are rebuilding. - 🇬🇪Georgia iamdroid
We tried this solution as well as all others listed in 🐛 Consider to remove exception handling from search_api_views_data Needs review . Unfortunately, nothing helped. The issue indeed occurs not always and seems like it is related to site visitors' activity.
In our particular case we not even using Search API views, the issue is triggered by a decouple request to the Drupal backend. So we are going to try to fix it on the upper level by avoiding calling hook_views_data or something like this. But It's interesting to know how it eventually ends up.Thanks @nicolas bouteille for sharing your findings.