When there is heavy load I am getting the

PDOException: SQLSTATE[40001]: Serialization failure: 1213 Deadlock found when trying to get lock; try restarting transaction: INSERT INTO {domain_source} (nid, domain_id) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1); Array
(
    [:db_insert_placeholder_0] => 101712
    [:db_insert_placeholder_1] => 0
)

this is called in hook_node_update(). Any Idea on solution ?

Comments

Letharion’s picture

Category: bug » support
Priority: Critical » Normal

Updating the category and priority of the issue.

Please read the instructions on how those fields work before posting issues.

Letharion’s picture

Status: Active » Postponed (maintainer needs more info)

Actually, you should probably try with a recent version of the module, instead of that year old release. Please try 2.19 and report back.

Dinesh Kumar Sarangapani’s picture

Hi Letharion,

Thank you, will try with new release and will report.

agentrickard’s picture

Status: Postponed (maintainer needs more info) » Closed (works as designed)

Well, this is a general MySQL failure symptomatic of a larger issue. We cannot provide module-specific support here. The transaction lock is part of node_save().

This issue might be re-opened as a core support issue if you fail to find a solution.

Dinesh Kumar Sarangapani’s picture

Thanks agentrickard, I am trying out with new domain module and also searching for solution. Will move to core issue if am not finding any solution

Dinesh Kumar Sarangapani’s picture

Status: Closed (works as designed) » Active

Updated to the latest stable release of Domain module (7.x-3.4), followed the same stress test posted in the Drupal core issue . Added the domains as part of node object.


/**
 * Root directory of Drupal installation.
 */
define('DRUPAL_ROOT', getcwd());

include_once DRUPAL_ROOT . '/includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);


for ($i = 0; $i < 5000; $i++) {
  $node = (object) array(
    'type' => 'article',
    'domain_source' => 2,
    'domains' => array(2 => 2),
    'domain_site' => 1,
    'domain_access' => 2,
    'status' => 1,
    'uid' => 1,
    'title' => 'Dummy node',
    'body' => array(
      LANGUAGE_NONE => array(
        0 => array(
          'value' => 'Dummy body',
          'format' => 'filtered_html',
        ),
      ),
    ),
  );
  node_save($node);
}

Executed with concurrency (for example with seq 1 100 | xargs -L 1 -P 15 drush php-script stress-node.script), Found Deadlock in

WD node: PDOException: SQLSTATE[40001]: Serialization failure: 1213 Deadlock found when trying to get lock; try   [error]
restarting transaction: INSERT INTO {domain_access} (nid, gid, realm) VALUES (:db_insert_placeholder_0,
:db_insert_placeholder_1, :db_insert_placeholder_2); Array
(
    [:db_insert_placeholder_0] => 1605238
    [:db_insert_placeholder_1] => 2
    [:db_insert_placeholder_2] => domain_id
)
 in _domain_store_grants() (line 2050 of
/var/www/drupal/sites/all/modules/contrib_modules/domain/domain.module).
WD php: PDOException: SQLSTATE[40001]: Serialization failure: 1213 Deadlock found when trying to get lock; try    [error]
restarting transaction: INSERT INTO {domain_access} (nid, gid, realm) VALUES (:db_insert_placeholder_0,
:db_insert_placeholder_1, :db_insert_placeholder_2); Array
(
    [:db_insert_placeholder_0] => 1605238
    [:db_insert_placeholder_1] => 2
    [:db_insert_placeholder_2] => domain_id
)
 in _domain_store_grants() (line 2050 of
/var/www/drupal/sites/all/modules/contrib_modules/domain/domain.module).

The innodb status is

| InnoDB |      | 
=====================================
121102 14:21:23 INNODB MONITOR OUTPUT
=====================================
Per second averages calculated from the last 3 seconds
----------
SEMAPHORES
----------
OS WAIT ARRAY INFO: reservation count 247864, signal count 247470
Mutex spin waits 0, rounds 1195699, OS waits 5639
RW-shared spins 378430, OS waits 185895; RW-excl spins 96808, OS waits 54060
------------------------
LATEST DETECTED DEADLOCK
------------------------
121102 14:20:43
*** (1) TRANSACTION:
TRANSACTION 0 4908076, ACTIVE 0 sec, process no 14592, OS thread id 2898492272 inserting
mysql tables in use 1, locked 1
LOCK WAIT 8 lock struct(s), heap size 1024, 3 row lock(s), undo log entries 5
MySQL thread id 49749, query id 8135639 192.168.4.4 phactuser update
INSERT INTO domain_access (nid, gid, realm) VALUES ('46084', '0', 'domain_site'), ('46084', '2', 'domain_id')
*** (1) WAITING FOR THIS LOCK TO BE GRANTED:
RECORD LOCKS space id 0 page no 851010 n bits 432 index "PRIMARY" of table "greenland_deadlock"."domain_access" trx id 0 4908076 lock_mode X insert intention waiting
Record lock, heap no 1 PHYSICAL RECORD: n_fields 1; compact format; info bits 0
 0: len 8; hex 73757072656d756d; asc supremum;;

*** (2) TRANSACTION:
TRANSACTION 0 4908078, ACTIVE 0 sec, process no 14592, OS thread id 2904111984 inserting, thread declared inside InnoDB 500
mysql tables in use 1, locked 1
8 lock struct(s), heap size 1024, 3 row lock(s), undo log entries 5
MySQL thread id 49753, query id 8135640 192.168.4.4 phactuser update
INSERT INTO domain_access (nid, gid, realm) VALUES ('46085', '0', 'domain_site'), ('46085', '2', 'domain_id')
*** (2) HOLDS THE LOCK(S):
RECORD LOCKS space id 0 page no 851010 n bits 432 index "PRIMARY" of table "greenland_deadlock"."domain_access" trx id 0 4908078 lock_mode X
Record lock, heap no 1 PHYSICAL RECORD: n_fields 1; compact format; info bits 0
 0: len 8; hex 73757072656d756d; asc supremum;;

*** (2) WAITING FOR THIS LOCK TO BE GRANTED:
RECORD LOCKS space id 0 page no 851010 n bits 432 index "PRIMARY" of table "greenland_deadlock"."domain_access" trx id 0 4908078 lock_mode X insert intention waiting
Record lock, heap no 1 PHYSICAL RECORD: n_fields 1; compact format; info bits 0
 0: len 8; hex 73757072656d756d; asc supremum;;

*** WE ROLL BACK TRANSACTION (2)
------------
TRANSACTIONS
------------
Trx id counter 0 4913696
Purge done for trx's n:o < 0 4913389 undo n:o < 0 0
History list length 164
LIST OF TRANSACTIONS FOR EACH SESSION:
---TRANSACTION 0 0, not started, process no 14592, OS thread id 2900900720
MySQL thread id 49755, query id 8183169 192.168.4.4 phactuser
SHOW ENGINE INNODB STATUS
---TRANSACTION 0 4913695, ACTIVE 0 sec, process no 14592, OS thread id 2898492272 inserting, thread declared inside InnoDB 500
mysql tables in use 1, locked 1
3 lock struct(s), heap size 320, 1 row lock(s), undo log entries 3
MySQL thread id 49749, query id 8183170 192.168.4.4 phactuser update
INSERT INTO field_data_body (entity_type, entity_id, revision_id, bundle, delta, language, body_value, body_summary, body_format) VALUES ('node', '48879', '49412', 'article', '0', 'und', 'Dummy body', NULL, 'filtered_html')
--------
FILE I/O
--------
I/O thread 0 state: waiting for i/o request (insert buffer thread)
I/O thread 1 state: waiting for i/o request (log thread)
I/O thread 2 state: waiting for i/o request (read thread)
I/O thread 3 state: waiting for i/o request (write thread)
Pending normal aio reads: 0, aio writes: 0,
 ibuf aio reads: 0, log i/o's: 0, sync i/o's: 0
Pending flushes (fsync) log: 0; buffer pool: 0
1316717 OS file reads, 1059070 OS file writes, 855391 OS fsyncs
9.66 reads/s, 16384 avg bytes/read, 81.31 writes/s, 80.97 fsyncs/s
-------------------------------------
INSERT BUFFER AND ADAPTIVE HASH INDEX
-------------------------------------
Ibuf: size 1, free list len 11, seg size 13,
25808 inserts, 25808 merged recs, 4564 merges
Hash table size 34679, node heap has 7 buffer(s)
3456.51 hash searches/s, 3090.30 non-hash searches/s
---
LOG
---
Log sequence number 19 1800780662
Log flushed up to   19 1800779562
Last checkpoint at  19 1798594112
0 pending log writes, 0 pending chkp writes
823951 log i/o's done, 80.31 log i/o's/second
----------------------
BUFFER POOL AND MEMORY
----------------------
Total memory allocated 55055266; in additional pool allocated 1048576
Dictionary memory allocated 31469720
Buffer pool size   512
Free buffers       1
Database pages     504
Modified db pages  160
Pending reads 0
Pending writes: LRU 0, flush list 0, single page 0
Pages read 1795101, created 148132, written 477518
9.66 reads/s, 4.67 creates/s, 3.33 writes/s
Buffer pool hit rate 1000 / 1000
--------------
ROW OPERATIONS
--------------
1 queries inside InnoDB, 0 queries in queue
1 read views open inside InnoDB
Main thread process no. 14592, id 2933046128, state: sleeping
Number of rows inserted 2104748, updated 574005, deleted 440358, read 58938973
862.05 inserts/s, 78.64 updates/s, 156.61 deletes/s, 470.18 reads/s
----------------------------
END OF INNODB MONITOR OUTPUT
============================
 
1 row in set (0.01 sec)

Will this information help ? Should this issue be posted to Drupal's core ?

agentrickard’s picture

Status: Active » Closed (works as designed)

Core. As an attachment. My understanding is that the lock is part of the node_save() transaction.