SQLSTATE[40001]: Serialization failure: 1213 Deadlock found when trying to get lock;

We are building an application in drupal 8.5.3(DB : MariaDB). Sometime we get sql dead lock issues in application under two circumstances.

  1. Running drush cr command and accessing application through browser concurrently.
  2. Clearing drupal cache from admin UI.

Below is the details of error message appeared in browser.

“The website encountered an unexpected error. Please try again later.</br></br><em class=”placeholder”>DrupalCoreDatabaseDatabaseExceptionWrapper</em>: 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_147, :db_insert_placeholder_148, :db_insert_placeholder_149, :db_insert_placeholder_150, :db_insert_placeholder_151, :db_insert_placeholder_152, :db_insert_placeholder_153) 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); ”

 Kindly let us know if you have any solution to resolve this issue. TIA

Drupal version: 


Source: https://www.drupal.org/taxonomy/term/22/feed