Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Error:
PDOException: SQLSTATE[40P01]: Deadlock detected: 7 ERROR: deadlock detected DETAIL: Process 30270 waits for AccessExclusiveLock on relation 2442958 of database 2434599; blocked by process 30269. Process 30269 waits for AccessExclusiveLock on relation 2442958 of database 2434599; blocked by process 30270. HINT: See server log for query details.: TRUNCATE {cache_entity_node} ; Array ( ) in cache_clear_all() (line 176 of /var/www/drupal/ec-internet/releases/20121212-1/includes/cache.inc).
I've seen this issue popup twice since enabling entitycache module, I have no clue what's causing it as it's seemingly random, but according to the logs it's caused by multiple truncates in short succession by different processes. Somehow this causes the node table to be updated with a non existent vid, which in turn causes all sorts of issues when using entity metadata wrappers etc.
example_db=> select * from node where nid = 631;
nid | vid | type | language | title | uid | status | created | changed | comment | promote | sticky | tnid | translate
-----+------+--------------+----------+-------------+-----+--------+------------+------------+---------+---------+--------+------+-----------
631 | 3767 | landing_page | und | Past Events | 24 | 1 | 1351899901 | 1355358716 | 0 | 0 | 0 | 0 | 0
(1 row)
example_db=> select * from node_revision where vid = 3767;
nid | vid | uid | title | log | timestamp | status | comment | promote | sticky
-----+-----+-----+-------+-----+-----------+--------+---------+---------+--------
(0 rows)
Has anyone else had this problem?
Comments
Comment #1
acbramley CreditAttribution: acbramley commentedComment #2
acbramley CreditAttribution: acbramley commentedWorked out how to replicate, if you hit the save button over and over on updating a node
Comment #3
acbramley CreditAttribution: acbramley commentedI'm on postgres 9.1 btw
Comment #4
acbramley CreditAttribution: acbramley commentedCan confirm disabling entitycache and doing the same thing does not produce the error
Comment #5
acbramley CreditAttribution: acbramley commentedHave continued testing this and have found more exceptions from the same action:
Comment #6
acbramley CreditAttribution: acbramley commentedReally wish this issue would get some attention, this is causing us major issues
Comment #7
acbramley CreditAttribution: acbramley commentedMarking as duplicate of #1839998: TruncateQuery implemented as "DELETE FROM" in MySQL and SQLite, but not PostgreSQL, causing nefarious table locking
Comment #8
wiifmNope, I have a core patch applied from #1839998: TruncateQuery implemented as "DELETE FROM" in MySQL and SQLite, but not PostgreSQL, causing nefarious table locking, and the deadlock is still apparent, this time the deadlock is with a "DELETE FROM" SQL command:
Comment #9
deanflory CreditAttribution: deanflory commentedI too have been getting these deadlocks after enabling the module.
Comment #10
Dave ReidThere is no patch here that needs work nor review. Can we have some detailed steps to reproduce this bug using a fresh install of core + Entity cache + minimum amount of contrib modules? Since this seems to affect PgSQL only, bumping down to major.
Comment #11
catchYou should use memcache or redis if you have a high concurrency site. This module makes pretty much zero sense with the database cache - it's purpose is to offload queries from the database for scalability, you don't get much benefit using it with the database cache.
Also Entity Cache only uses core's cache API - so this is either a problem with the postgres driver for core, or possibly your database configuration (MySQL at least has settings which can increase or decrease the likelihood for gap locks), but it's not a specific bug in entity cache - it's just exposing the bug elsewhere.