Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[5.x]: Mutex exception because of propagation method "Only save entries to the site they were created in" after upgrade from 4.x #16487

Open
peter0503 opened this issue Jan 22, 2025 · 7 comments
Labels

Comments

@peter0503
Copy link

What happened?

Description

After upgrading from version 4.12.3 to 5.6.0.2, we encountered a mutex exception when creating a new page entry. This issue arises due to the propagation method "Only save entries to the site they were created in" on a field used in the entry type. If we switch to another propagation method, it works correctly. Previously, this field used a Super Table in version 4.x, and in version 5.x, we are using Matrix instead of the Super Table. We performed the migration through the console to migrate all Super Table fields.

Steps to reproduce

  1. Upgrade from 4.12.3 to 5.6.0.2
  2. Create a new "page entry"

Expected behavior

Should open me the entry and I should be able to fill out the the data

Actual behavior

Mutex Exception – craft\errors\MutexException
Unable to acquire a lock for the structure 1

Craft CMS version

Craft Pro 5.6.0.2

PHP version

8.3.16

Operating system and version

Linux 5.10.228-219.884.amzn2.x86_64

Database type and version

PostgreSQL 14.12

Image driver and version

GD 8.3.16

Installed plugins and versions

Plugin Version
Amazon S3 2.2.1
Amazon SES 3.1.0
Code Field 5.0.0
Control Panel CSS 3.0.0
Control Panel JS 3.0.0
CP Field Inspect 2.0.3
Element Relations 3.0.6
Feed Me 6.6.1
Guide 5.2.0
Hyper 2.2.2
Icon Picker 3.0.2
ImageOptimize 5.0.4
Navigation 3.0.5
Neo 5.2.22
Preparse 3.0.0-alpha.2
Redactor 4.2.0
Retour 5.0.5
SEOmatic 5.1.10
Static Translations 4.1.1
Super Dynamic Fields 5.0.1
Super Table 4.0.2
Translations v4.0.6
Workflow 3.0.5
@peter0503 peter0503 added the bug label Jan 22, 2025
@peter0503 peter0503 changed the title [5.x]: Mutex exception because of propagation mehtod "Only save entries to the site they were created in" after upgrade from 4.x [5.x]: Mutex exception because of propagation method "Only save entries to the site they were created in" after upgrade from 4.x Jan 24, 2025
@peter0503
Copy link
Author

Update:
Only the "Save entries to all sites the owner element is saved in" does work. We can also provide a database dump if needed.

@i-just
Copy link
Contributor

i-just commented Jan 24, 2025

Hi, thanks for getting in touch. To start with, can you please post a full stack trace for the error you’re getting? Also, are you using a custom mutex component?

@peter0503
Copy link
Author

peter0503 commented Jan 24, 2025

We do not have a custom mutex entry in the app.php.

Stacktrace:

craft\errors\MutexException: Unable to acquire a lock for the structure 1 in /app/vendor/craftcms/cms/src/services/Structures.php:511
Stack trace:
#0 /app/vendor/craftcms/cms/src/services/Structures.php(375): craft\services\Structures->_doIt()
#1 /app/vendor/craftcms/cms/src/elements/Entry.php(2713): craft\services\Structures->appendToRoot()
#2 /app/vendor/craftcms/cms/src/elements/Entry.php(2654): craft\elements\Entry->_placeInStructure()
#3 /app/vendor/craftcms/cms/src/services/Elements.php(3775): craft\elements\Entry->afterSave()
#4 /app/vendor/craftcms/cms/src/services/Elements.php(1217): craft\services\Elements->craft\services\{closure}()
#5 /app/vendor/craftcms/cms/src/services/Elements.php(3580): craft\services\Elements->ensureBulkOp()
#6 /app/vendor/craftcms/cms/src/services/Elements.php(1303): craft\services\Elements->_saveElementInternal()
#7 /app/vendor/craftcms/cms/src/services/Drafts.php(261): craft\services\Elements->saveElement()
#8 /app/vendor/craftcms/cms/src/controllers/EntriesController.php(185): craft\services\Drafts->saveElementAsDraft()
#9 [internal function]: craft\controllers\EntriesController->actionCreate()
#10 /app/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array()
#11 /app/vendor/yiisoft/yii2/base/Controller.php(178): yii\base\InlineAction->runWithParams()
#12 /app/vendor/yiisoft/yii2/base/Module.php(552): yii\base\Controller->runAction()
#13 /app/vendor/craftcms/cms/src/web/Application.php(361): yii\base\Module->runAction()
#14 /app/vendor/yiisoft/yii2/web/Application.php(103): craft\web\Application->runAction()
#15 /app/vendor/craftcms/cms/src/web/Application.php(329): yii\web\Application->handleRequest()
#16 /app/vendor/yiisoft/yii2/base/Application.php(384): craft\web\Application->handleRequest()
#17 /app/web/index.php(21): yii\base\Application->run()
#18 {main}

@brandonkelly
Copy link
Member

How exactly are you coming to the conclusion that the section’s propagation method is the culprit here? Have you tried changing the section’s propagation method? Or are you just not seeing the same issue with other sections (which have different propagation methods selected)?

I’m not able to reproduce the error regardless of propagation method.

The stack trace says the error is happening here:

$lockName = 'structure:' . $structureId;
$mutex = Craft::$app->getMutex();
if (!$mutex->acquire($lockName, $this->mutexTimeout)) {
throw new MutexException($lockName, sprintf('Unable to acquire a lock for the structure %s', $structureId));
}

Which is only going to get called once regardless of propagation method.

Most likely, the database has a lock on stucture:<ID> that didn’t get released properly for some reason. If you restart your database server, the error should go away.

@peter0503
Copy link
Author

peter0503 commented Jan 27, 2025

We nailed it down to a field. Then we removed the field and it does work. After adding it again it is failing again, so we tried to change the propagation method and as I mentioned above if we choose the ""Save entries to all sites the owner element is saved in" id does work, but for all other on this field it does not. Here is a screenshot of our field which causes this behavior.

Image

As mentioned above, we could also provide a database dump.

We also restartet our system and also destroyed all containers, even the db container, since we are on aws.

@brandonkelly
Copy link
Member

Can you send your database and Composer files into support@craftcms.com so we can look into it from our end?

@peter0503
Copy link
Author

Sent you the required files to the mail mentioned.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants