Cms: Could not acquire a lock to save a revision for element

Created on 17 Aug 2020  路  9Comments  路  Source: craftcms/cms

Description

Stumbled across this issue a few times now. I'm unable to Save as a new {type} when editing an entry. I can however duplicate an entry by checking it from the element index.

2020-08-14 14:46:47 [-][1][...][error][yii\db\Exception] yii\db\Exception: Could not acquire a lock to save a revision for element 11533 in /.../vendor/craftcms/cms/src/services/Revisions.php:78
Stack trace:
#0 /.../vendor/craftcms/cms/src/elements/Entry.php(1477): craft\services\Revisions->createRevision(Object(craft\elements\Entry), NULL, NULL)
#1 /.../vendor/craftcms/cms/src/services/Elements.php(2372): craft\elements\Entry->afterPropagate(false)
#2 /.../vendor/craftcms/cms/src/services/Elements.php(691): craft\services\Elements->_saveElementInternal(Object(craft\elements\Entry), true, false, true)
#3 /.../vendor/craftcms/cms/src/controllers/EntriesController.php(380): craft\services\Elements->saveElement(Object(craft\elements\Entry))
#4 [internal function]: craft\controllers\EntriesController->actionSaveEntry(true)
#5 /.../vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)
#6 /.../vendor/yiisoft/yii2/base/Controller.php(180): yii\base\InlineAction->runWithParams(Array)
#7 /.../vendor/craftcms/cms/src/web/Controller.php(181): yii\base\Controller->runAction('save-entry', Array)
#8 /.../vendor/craftcms/cms/src/controllers/EntriesController.php(439): craft\web\Controller->runAction('save-entry', Array)
#9 [internal function]: craft\controllers\EntriesController->actionDuplicateEntry()
#10 /.../vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)
#11 /.../vendor/yiisoft/yii2/base/Controller.php(180): yii\base\InlineAction->runWithParams(Array)
#12 /.../vendor/craftcms/cms/src/web/Controller.php(181): yii\base\Controller->runAction('duplicate-entry', Array)
#13 /.../vendor/yiisoft/yii2/base/Module.php(528): craft\web\Controller->runAction('duplicate-entry', Array)
#14 /.../vendor/craftcms/cms/src/web/Application.php(294): yii\base\Module->runAction('entries/duplica...', Array)
#15 /.../vendor/craftcms/cms/src/web/Application.php(597): craft\web\Application->runAction('entries/duplica...', Array)
#16 /.../vendor/craftcms/cms/src/web/Application.php(273): craft\web\Application->_processActionRequest(Object(craft\web\Request))
#17 /.../vendor/yiisoft/yii2/base/Application.php(386): craft\web\Application->handleRequest(Object(craft\web\Request))
#18 /.../web/index.php(40): yii\base\Application->run()
#19 {main}

Steps to reproduce

  1. Edit an entry
  2. Click Save as a new {type} in the save-button dropdown.

Additional info

  • Craft version: 3.5.3
  • PHP version: 7.2.24
bug

Most helpful comment

I鈥檓 not able to reproduce this. Can you please send a database backup and your Composer files over to [email protected] so we can try reproducing it on your install?

All 9 comments

I just noticed there was another update, this issue is still active in 3.5.4.

I鈥檓 not able to reproduce this. Can you please send a database backup and your Composer files over to [email protected] so we can try reproducing it on your install?

I am facing this error. Is this ticket solved?

I am using craft 3.5.9

image

Have also just had a client report this problem on Craft 3.4.30 and PHP version 7.0.33

If you are able to reproduce it, please send a database backup and your Composer files over to [email protected] and we can look into it from there.

Hello @brandonkelly, I am experiencing the same issue while trying to duplicate an entry.
I just sent the email to support@ with the required files. Thanks!

At least in one case we鈥檝e now looked into, this was due to an EVENT_AFTER_SAVE event handler which was trying to resave revision entries. The fix was to ensure that the entry being saved wasn鈥檛 a draft or revision:

if (ElementHelper::isDraftOrRevision($entry)) {
    return;
}

I still have this problem with Craft CMS 3.6.6 PRO
It does make a new entry but trow this error:

yii\db\Exception: Could not acquire a lock to save a revision for element 7056 in /home/****/domains/****.nl/project/vendor/craftcms/cms/src/services/Revisions.php:78
Stack trace:
#0 /home/****/domains/****.nl/project/vendor/craftcms/cms/src/elements/Entry.php(1585): craft\services\Revisions->createRevision(Object(craft\elements\Entry), NULL, '')
#1 /home/****/domains/****.nl/project/vendor/craftcms/cms/src/services/Elements.php(2502): craft\elements\Entry->afterPropagate(false)
#2 /home/****/domains/****.nl/project/vendor/craftcms/cms/src/services/Elements.php(755): craft\services\Elements->_saveElementInternal(Object(craft\elements\Entry), true, true, true)
#3 /home/****/domains/****.nl/project/vendor/craftcms/cms/src/controllers/EntriesController.php(382): craft\services\Elements->saveElement(Object(craft\elements\Entry))
#4 [internal function]: craft\controllers\EntriesController->actionSaveEntry(true)
#5 /home/****/domains/****.nl/project/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)
#6 /home/****/domains/****.nl/project/vendor/yiisoft/yii2/base/Controller.php(181): yii\base\InlineAction->runWithParams(Array)
#7 /home/****/domains/****.nl/project/vendor/craftcms/cms/src/web/Controller.php(190): yii\base\Controller->runAction('save-entry', Array)
#8 /home/****/domains/****.nl/project/vendor/craftcms/cms/src/controllers/EntriesController.php(441): craft\web\Controller->runAction('save-entry', Array)
#9 [internal function]: craft\controllers\EntriesController->actionDuplicateEntry()
#10 /home/****/domains/****.nl/project/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)
#11 /home/****/domains/********nce.nl/project/vendor/yiisoft/yii2/base/Controller.php(181): yii\base\InlineAction->runWithParams(Array)
#12 /home/****/domains/****.nl/project/vendor/craftcms/cms/src/web/Controller.php(190): yii\base\Controller->runAction('duplicate-entry', Array)
#13 /home/****/domains/****.nl/project/vendor/yiisoft/yii2/base/Module.php(534): craft\web\Controller->runAction('duplicate-entry', Array)
#14 /home/****/domains/****.nl/project/vendor/craftcms/cms/src/web/Application.php(274): yii\base\Module->runAction('entries/duplica...', Array)
#15 /home/****/domains/****.nl/project/vendor/craftcms/cms/src/web/Application.php(577): craft\web\Application->runAction('entries/duplica...', Array)
#16 /home/****/domains/****.nl/project/vendor/craftcms/cms/src/web/Application.php(253): craft\web\Application->_processActionRequest(Object(craft\web\Request))
#17 /home/****/domains/****.nl/project/vendor/yiisoft/yii2/base/Application.php(392): craft\web\Application->handleRequest(Object(craft\web\Request))
#18 /home/****/domains/****.nl/project/web/index.php(22): yii\base\Application->run()
#19 {main}
Additional Information:
Array
(
)

@dimitrihilverda Is that happening consistently? Are you overriding the mutex component in config/app.php by chance?

Was this page helpful?
0 / 5 - 0 ratings