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

The "An unknown error occurred" when saving roles #4695

Closed
VladimirVershinin opened this issue Nov 25, 2023 · 3 comments
Closed

The "An unknown error occurred" when saving roles #4695

VladimirVershinin opened this issue Nov 25, 2023 · 3 comments

Comments

@VladimirVershinin
Copy link

Describe the Bug

Hello.
We have a lot of pages, books and shelves inside our bookstack service.
Now we have An unknown error occurred" we try to save any role via bookstack web interface.
The "production.ERROR: SQLSTATE[HY000]: General error: 1390 Prepared statement contains too many placeholders (SQL: select entity_id, entity_type, role_id, view from entity_permissions where .. " record is placed into our laravel.log when error occurs.

As side effect, after saving any role some users lost his access to some books and shelves. So I need to restore it with
"php artisan bookstack:regenerate-permissions " bookstack command.

To remove same error from regenerate-permission command I have increase my mariadb
max_allowed_packet parameter to 1073741824

This mariadb reconfiguration was helpful for cli-command, but not for "Save Role" button

Steps to Reproduce

  1. Go to Settings ->Roles
  2. Select any role ( go to Edit Role page)
  3. Click Save Role
  4. See error

Expected Behaviour

Instead of error page we expected to see refreshed Edit Role page. Also we excepted that saving role will not break user access to bookstack objects.

Screenshots or Additional Context

laravel.log.gz
изображение

Browser Details

Firefox 115.5.0esr linux

Exact BookStack Version

v23.10.4

@digitlimit
Copy link

@ssddanbrown is it okay If I fix and create a PR for this?

@ssddanbrown
Copy link
Member

@digitlimit Sure, go ahead, but I've marked this for the next feature release (targeting end of year) so ideally any PR would be in by the end of next week. If that's okay and you want to take it on let me know and I'll assign this to you.

ssddanbrown added a commit that referenced this issue Dec 23, 2023
Query of existing entity permissions during view permission generation
could cause timeouts or SQL placeholder limits due to massive whereOr
query generation, where an "or where" clause would be created for each
entity type/id combo involved, which could be all within 20 books.

This updates the query handling to use a query per type involved, with
no "or where"s, and to be chunked at large entity counts.

Also tweaked role-specific permission regen to chunk books at
half-previous rate to prevent such a large scope being involved on each
chunk.

For #4695
@ssddanbrown
Copy link
Member

I've now made changes in 02d94c8 with the intent to address this.
The erroring query is now done in a more scale-aware & scale-efficient way that'll better handle large amounts of content.

This will be part of the next feature release, due at the end of this month.
Thanks @VladimirVershinin for raising and detailing the issue.

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

No branches or pull requests

3 participants