In database it is giving below error from log.
[error] Drupal\Core\Database\DatabaseExceptionWrapper: SQLSTATE[HY000]: General error: 1205 Lock wait timeout exceeded; try restarting transaction: DELETE FROM {autosave_form_entity_form}
WHERE (entity_type_id = :db_condition_placeholder_0) AND (entity_id = :db_condition_placeholder_1); Array
(
[:db_condition_placeholder_0] => media
[:db_condition_placeholder_1] => 716136
)
in autosave_form_entity_update() (line 112 of /..../modules/contrib/autosave_form/autosave_form.module).
Issue fork autosave_form-3029155
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
shahankitb commentedComment #3
hchonovI don't think that this issue is triggered by the autosave_form module. To me it looks like that it adds a little overhead and then you exceed your lock wait timeout.
What is the value of
innodb_lock_wait_timeoutof your database? How long does it take to save that particular entity (media, ID 716136) without having autosave_form enabled?Comment #4
hchonovComment #7
mediabounds commentedWe are periodically running into this issue to and I _believe_ it happens when many entities are being updated/deleted at about the same time.
Regardless of whether an entity has a form or has any entries in autosave_form_entity_form, when an entity changes, a call is made to AutosaveEntityFormStorageInterface::purgeAutosavedEntityState. The resulting query is going to look like:
DELETE FROM `autosave_form_entity_form` WHERE ( `entity_type_id` = ? ) AND ( `entity_id` = ? )Since the PRIMARY index is not suitable for this, it results in the whole table having to be scanned (even if there are no matching records). So if there are many autosave entries or many subsequent entity updates, the row locks may start backing up and eventually time out.
Adding an index that covers entity_type_id and entity_id seems to cover this scenario.
Comment #8
mediabounds commentedComment #9
alexj12 commentedConfirming that we ran into this issue recently and during an incident applied the same indexes which resolved the issue. The fact that the current PRIMARY index is composite means it isn't used in the troublesome query.
Reviewed and tested by the community!
Comment #10
alexj12 commentedLink to the documentation outlining that the order of the columns in the index is important and the current PRIMARY index does not optimise the query.
Comment #12
hchonovThank you. This will be part of the 1.6 release.
Comment #14
rajeshreeputraThis introduced error on upgrade please see - #3497311: update hook autosave_form_update_8004 throws error