My site is getting occasional deadlock issues when attempting to bulk moderate comments.
Uncaught PHP Exception Drupal\\Core\\Entity\\EntityStorageException: "SQLSTATE[40001]: Serialization failure: 1213 Deadlock found when trying to get lock; try restarting transaction:
UPDATE {comment_entity_statistics}
SET
cid=:db_update_placeholder_0,
comment_count=:db_update_placeholder_1,
last_comment_timestamp=:db_update_placeholder_2,
last_comment_name=:db_update_placeholder_3,
last_comment_uid=:db_update_placeholder_4
WHERE (
(entity_id = :db_condition_placeholder_0)
AND (entity_type = :db_condition_placeholder_1)
AND (field_name = :db_condition_placeholder_2)
);
Array
(
[:db_update_placeholder_0] => 142138
[:db_update_placeholder_1] => 114653
[:db_update_placeholder_2] => 1492717609
[:db_update_placeholder_3] =>
[:db_update_placeholder_4] => 222123
[:db_condition_placeholder_0] => 28323
[:db_condition_placeholder_1] => node
[:db_condition_placeholder_2] => field_comments
)
" at /var/www/html/releases/20170404135337/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php line 770
core/modules/rest/src/Plugin/rest/resource/EntityResource.php line 182
Comments
Comment #2
kier.heyl commentedCould be a scaling issue? We have over 110,000 comments on one entity.
Could be a custom code issue. The bulk action is a custom one and not the base unpublish. Though honestly the only difference is that I've added a field to my comments called reviewed, and this bulk option marks reviewed as true in addition to marking the content as unpublished.
Could be a version issue. Just need to update to latest stable?
Happens every once in a while, but not consistently. Happens more when I have more than one person trying to moderate at once.
Comment #3
kier.heyl commentedI tried recreating it in our dev environment where we have a fraction of the comments and could not do so. I'm working on generating comments in dev to see if it is truly volume related.
If that is the case any advice on how to get around this?
Is this a case where the scale of the number of comments we're getting is inappropriate to what Drupal is designed to handle? Is there an alternate convention that might be better and still function correctly inside of drupal?
Comment #4
kier.heyl commentedOnce I hit about 20,000 comments it looks like I can pretty reliably re-create this issue.
Steps to re-create:
1. Generate like 20,000 comments.
2. Login with two different users and unpublish two different sets of comments simultaneously.
3. One user (at random) gets a response that they couldn't unpublish the comments. The other comments unpublish normally.
Comment #5
cilefen commentedComment #6
kier.heyl commentedLooks like drupal offers a state object to set states for internal programming use, and it looks like comment statistics comes with a state value where you can enable/disable tracking.
My workaround for now was to overwrite the default executeMultiple function on ActionBase and set it to group all comments based on the entity they are commenting on. Then it pops the last element off of each of those arrays. Then it disables statistics processing and processes all of the elements in the array.
Once done it re-enables statistics processing and executes the action on the last element. This seems to correct the issue, but I don't know that it's 100% bullet proof.
Comment #7
schifazl commentedI occasionally get this same error, but it happens when content is created. The content creation will fail, the nid skipped, and the user must create again the node. Here's the log message:
Comment #8
rvanderh1 commentedI've been getting this error just starting today. Using Drupal 8.3.5. Happens when I clear cache and then try to go back to my site. A couple of days ago our server was released through the institution's firewall and everything on our site is redirected to https; I have no idea if that is a contributing factor.
Uncaught PHP Exception Drupal\\Core\\Database\\DatabaseExceptionWrapper: "SQLSTATE[40001]: Serialization failure: 1213 Deadlock found when trying to get lock; try restarting transaction: INSERT INTO {cache_config}
Comment #9
nor4a commentedSame error when cleaning the caches.
Comment #10
othermachines commentedThis occurred for me on 8.3.7 when I loaded the homepage after clearing all caches.
Comment #11
othermachines commentedFollowing up on #10.
In case it helps, here is the output of
SHOW ENGINE INNODB STATUS:Comment #12
brulain commentedSame here until 8.4.2.
It happens randomly at any time : editing a node, checking updates, etc.
It's a serious problem on a production site.
Comment #13
finex commentedI'm experiencing a similar error (related to cache_config table) on a fresh D 8.4.3 install when enabling about 30 modules.
Comment #14
remram commentedI'm running to the same error by executing
$entity->save(). In my case: I'm trying to import data through custom REST endpoint and happend randomly!Comment #15
brunodboJust got this on 8.5-dev when editing a node.
Comment #16
brunodboThis looks like a duplicate of #2833539: SQLSTATE[40001]: Serialization failure: 1213 Deadlock (please reopen if anyone thinks they should be kept separate).
Comment #17
povilas uogintas commentedIt is happening on my rather complex site set up (NGINX / PHP7 / MariaDB / Drupal 8.4.2)....
Here is the latest error similar to previous ones...
It sometimes happens while doing
drush cror when clearing caches via UI .... And it even happened while site doing cron jobs...The main problem I found is that we have 3 drupal 8 sites on the same server... If any of get affected in turn it kills other sites and the only way to get them back is to perform restart of PHP-FPM ...
I do think this is rather serious issue as I cannot identify actual problem I only see symptoms like this popping up at random times without any real correlation...
Cheers,
Povilas
Comment #18
cilefen commentedHi @puogintas:
This issue has been closed as a duplicate. Please comment on #2833539: SQLSTATE[40001]: Serialization failure: 1213 Deadlock.
Comment #19
povilas uogintas commentedThanks @cilefen
Will do that now.