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

Structure In Unusable State #3148

Closed
mattcdavis1 opened this issue Jul 24, 2018 · 7 comments
Closed

Structure In Unusable State #3148

mattcdavis1 opened this issue Jul 24, 2018 · 7 comments

Comments

@mattcdavis1
Copy link

mattcdavis1 commented Jul 24, 2018

Description

At some point our structure has devolved into an unusable state. Reassigning an entry to a different parent doesn't work. Items show up under two parents at the same time. Expanding contracting doesn't work. Chunks of hierarchy are missing. See screenshot.

Also, here is a screenshot of an error i received when trying to remove a parent (to set element back to
the root of the structure)

Steps to reproduce

Still trying to figure this out. Structures in other areas of the CMS are working ok. Possibly related to depth?

Additional info

  • Craft version: Craft Pro 3.0.17
  • PHP version: 7.2.7
  • Database driver & version: MySQL 5.7.22
@mattcdavis1
Copy link
Author

Comparing with another area of the CMS where the structures are working, it looks like folding up items should not trigger an ajax call for get-more-elements but in the broken structure folding and unfolding both generate ajax calls form get-more-elements

@mattcdavis1 mattcdavis1 changed the title Structures In Unusable State Structure In Unusable State Jul 24, 2018
@brandonkelly
Copy link
Member

Can you send a database backup to support@craftcms.com ? We can look into it from there.

brandonkelly added a commit that referenced this issue Jul 24, 2018
@jcherniak
Copy link
Contributor

So I recently ran into this same issue trying to programatically create about 15000 entries. We created queue jobs for them, but when we ran the queue over 8 threads (on 2 hosts), the whole structure gets smashed.

In the fix you pushed, you just acquire the lock immediately and throw an exception if it fails. This is problematic because it will cause entry saving to fail in some instances.

Would it be possible to:

  1. Add a few second timeout to the mutex?
  2. Throw a custom exception class that could be caught in our job? This way I can detect I should just try to save again, versus just crap out.

I can just add a mutex around saving elements completely, but that's far less efficient than if we can do it here.

brandonkelly added a commit that referenced this issue Aug 4, 2018
@brandonkelly
Copy link
Member

@jcherniak I just added a mutexTimeout property to the Structures service class. Your queue jobs can either set this on the Craft::$app->structures singleton, or instantiate their own instances, with a custom mutexTimeout property.

It’s set to 0 by default, so there’s no change in behavior by default here. There’s no sense in giving it a timeout by default, because the structure UI isn’t collaborative. So if there’s a scenario where the structure is already locked, then one/both of the users are likely viewing inaccurate structure views.

@jcherniak
Copy link
Contributor

@brandonkelly Thanks for the amazingly quick resolution here!

@jcherniak
Copy link
Contributor

So looking into this further, it seems that Craft uses a yii\mutex\FileMutex. This doesn't work across load-balanced or worker-queue hosts. Any thoughts about using a DbMutex instead?

@brandonkelly
Copy link
Member

@jcherniak probably not a bad idea. Can you request in a separate issue?

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

No branches or pull requests

3 participants