verbb / navigation

A Craft CMS plugin to create navigation menus for your site.
Other
90 stars 23 forks source link

Adding multiple entries at once throws errors sometimes #182

Closed Mosnar closed 4 years ago

Mosnar commented 4 years ago

Description If I click to add an entry, I'm allowed to select multiple items (nice!). But once I click "Select", many of those items result in an error notification at the top of the screen. Inspecting the network tab, I see a few successful calls to save-node as well as some 500 errors:

{"error":"Unable to acquire a lock for the structure 12"}

Additional info

engram-design commented 4 years ago

Hmmm, I can't seem to reproduce this, and I've added 10-15 different entries in one go, a couple of different times. Anything of note with your site setup, like database driver (MySQL or Postgres)? Any special server setups?

I asked @brandonkelly to comment on the underlying issue here:

Typically when we see mutex-related issues, it's because they're on a load-balanced environment, and haven't set each server to share the same data cache (https://craftcms.com/knowledge-base/configuring-load-balanced-environments#caching)

Anything related to your setup?

Sounds to me like something else is trying to update things, but I'll have to look into it further to try and reproduce this. I've had this very occasionally in the past with Craft itself (categories).

Mosnar commented 4 years ago

We're just now starting to roll this plugin into our new builds (hence all the tickets!), so not a lot of prior experience with the architecture.

We have two sites in development with the plugin installed, both separate dedicated Amazon Linux 2 Elastic Beanstalk servers. Both have this problem.

Here's the setup for both sites:

Here's the stack-trace from the error:

yii\base\Exception: Unable to acquire a lock for the structure 10 in /var/app/current/vendor/craftcms/cms/src/services/Structures.php:395
Stack trace:
#0 /var/app/current/vendor/craftcms/cms/src/services/Structures.php(285): craft\services\Structures->_doIt(10, Object(verbb\navigation\elements\Node), Object(craft\records\StructureElement), 'appendTo', 'auto')
#1 /var/app/current/vendor/verbb/navigation/src/elements/Node.php(516): craft\services\Structures->appendToRoot(10, Object(verbb\navigation\elements\Node))
#2 /var/app/current/vendor/craftcms/cms/src/services/Elements.php(2352): verbb\navigation\elements\Node->afterSave(true)
#3 /var/app/current/vendor/craftcms/cms/src/services/Elements.php(691): craft\services\Elements->_saveElementInternal(Object(verbb\navigation\elements\Node), true, false, true)
#4 /var/app/current/vendor/verbb/navigation/src/controllers/NodesController.php(41): craft\services\Elements->saveElement(Object(verbb\navigation\elements\Node), true, true)
#5 [internal function]: verbb\navigation\controllers\NodesController->actionSaveNode()
#6 /var/app/current/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)
#7 /var/app/current/vendor/yiisoft/yii2/base/Controller.php(180): yii\base\InlineAction->runWithParams(Array)
#8 /var/app/current/vendor/craftcms/cms/src/web/Controller.php(181): yii\base\Controller->runAction('save-node', Array)
#9 /var/app/current/vendor/yiisoft/yii2/base/Module.php(528): craft\web\Controller->runAction('save-node', Array)
#10 /var/app/current/vendor/craftcms/cms/src/web/Application.php(294): yii\base\Module->runAction('navigation/node...', Array)
#11 /var/app/current/vendor/craftcms/cms/src/web/Application.php(597): craft\web\Application->runAction('navigation/node...', Array)
#12 /var/app/current/vendor/craftcms/cms/src/web/Application.php(273): craft\web\Application->_processActionRequest(Object(craft\web\Request))
#13 /var/app/current/vendor/yiisoft/yii2/base/Application.php(386): craft\web\Application->handleRequest(Object(craft\web\Request))
#14 /var/app/current/web/index.php(22): yii\base\Application->run()
#15 {main}
Installed Plugins: Plugin Version
Amazon S3 1.2.9
CP Field Inspect 1.2.1
Element API 2.6.0
Elements Panel 1.1.0
Feed Me 4.2.3
Field Manager 2.1.8
Freeform 3.7.4
Mailgun 1.4.3
MatrixMate 1.2.7
Minify 1.2.10
Navigation 1.3.26
oEmbed 1.3.4
Preparse Field 1.2.1
Redactor 2.7.1
Redactor Split 1.1.0
Redirects 3.0.6
Retcon 2.2.1
SEOmatic 3.3.16
Super Table 2.6.1
Twigpack 1.2.5
Typed link field 2.0.0-beta.10
Typogrify 1.1.18
engram-design commented 4 years ago

Thanks for the info! Doesn't sound like you're using load-balancing, I wonder if it might be due to the remote MySQL (I guess this means it's on a different server to the Craft install right?)

Mosnar commented 4 years ago

Correct - no load balancing here. We've been using this setup for a couple years and have never had lock issues before.

engram-design commented 4 years ago

Should be fixed in 1.4.0. You should also notice a performance boost when adding new nodes.