Several Books are inaccessible. #1707

Closed
opened 2026-02-05 01:40:23 +03:00 by OVERLORD · 6 comments
Owner

Originally created by @mattstanyon-tall on GitHub (May 4, 2020).

Describe the bug
A number of books are inaccessible. While they still appear in their shelves from the Shelves view, when a book is directly selected, it errors Lost Books.txt, or if you drill down into a shelf the book no longer appears.

The data within the books seems to be accessible from the search.

When running the php artisan bookstack:copy-shelf-permissions --all --no-interaction command, we see errors in the laravel.log KB_copy-shelf-permiss.txt.

Looking into MySQL, we see the auto_increment value of the joint_permissions table is 4294967295, which seems to correspond to the following:
https://stackoverflow.com/questions/17690926/failed-to-read-auto-increment-value-from-storage-engine-error-number-1467/17690982

Interestingly, we see a huge jump in the value for the joint_permission id column (no idea if this is a problem, or expected, etc.). joint_permissions_ai_gaps.txt

Expected behavior
Books should not disappear!

Your Configuration (please complete the following information):

  • Exact BookStack Version (Found in settings):0.28.2
  • PHP Version:PHP 7.2.24-0ubuntu0.18.04.4
  • Hosting Method (Nginx/Apache/Docker): Apache2

Additional context
Add any other context about the problem here.

Originally created by @mattstanyon-tall on GitHub (May 4, 2020). **Describe the bug** A number of books are inaccessible. While they still appear in their shelves from the Shelves view, when a book is directly selected, it errors [Lost Books.txt](https://github.com/BookStackApp/BookStack/files/4573276/Lost.Books.txt), or if you drill down into a shelf the book no longer appears. The data within the books seems to be accessible from the search. When running the php artisan bookstack:copy-shelf-permissions --all --no-interaction command, we see errors in the laravel.log [KB_copy-shelf-permiss.txt](https://github.com/BookStackApp/BookStack/files/4573275/KB_copy-shelf-permiss.txt). Looking into MySQL, we see the auto_increment value of the joint_permissions table is 4294967295, which seems to correspond to the following: https://stackoverflow.com/questions/17690926/failed-to-read-auto-increment-value-from-storage-engine-error-number-1467/17690982 Interestingly, we see a huge jump in the value for the joint_permission id column (no idea if this is a problem, or expected, etc.). [joint_permissions_ai_gaps.txt](https://github.com/BookStackApp/BookStack/files/4573305/joint_permissions_ai_gaps.txt) **Expected behavior** Books should not disappear! **Your Configuration (please complete the following information):** - Exact BookStack Version (Found in settings):0.28.2 - PHP Version:PHP 7.2.24-0ubuntu0.18.04.4 - Hosting Method (Nginx/Apache/Docker): Apache2 **Additional context** Add any other context about the problem here.
OVERLORD added the 🔧 Maintenance🐛 Bug💿 Database🏭 Back-End labels 2026-02-05 01:40:23 +03:00
Author
Owner

@mattstanyon-tall commented on GitHub (May 4, 2020):

We ran the following commands which seems to have resolved the issues:

ALTER TABLE bookstack.joint_permissions DROP `id`;
ALTER TABLE bookstack.joint_permissions ADD `id` int(10) unsigned primary KEY NOT NULL AUTO_INCREMENT;

Although, we suspect it will come back. In addition, the following command is run hourly, which does seem to increase the auto_increment value on each run:

php artisan bookstack:copy-shelf-permissions --all --no-interaction
@mattstanyon-tall commented on GitHub (May 4, 2020): We ran the following commands which seems to have resolved the issues: ```SQL ALTER TABLE bookstack.joint_permissions DROP `id`; ALTER TABLE bookstack.joint_permissions ADD `id` int(10) unsigned primary KEY NOT NULL AUTO_INCREMENT; ``` Although, we suspect it will come back. In addition, the following command is run hourly, which does seem to increase the auto_increment value on each run: ```php php artisan bookstack:copy-shelf-permissions --all --no-interaction ```
Author
Owner

@ssddanbrown commented on GitHub (May 4, 2020):

Hi @mattstanyon-tall,
Thanks for extensive detail and investigation you've done so far.

I've wondered when we'd first come up against a 32bit integer id issue. At a rough guess the php artisan bookstack:copy-shelf-permissions --all command will effectively delete and insert:

(number of shelves) x (number of roles) x (number of child books, chapters & pages within a shelf) x (~ 4 different permissions)

Can increase very quickly if the number of entities or roles is high in your instance, Then coupled with running that every hour.

Still, 4 billion is a big number. I wonder if the way the batch operations cause MySQL to jump the id much further than expected.

I've assigned this to be looked at for the next release. I'll check if the id value is really needed or look at changing the permission generation process & column type if it is needed.

@ssddanbrown commented on GitHub (May 4, 2020): Hi @mattstanyon-tall, Thanks for extensive detail and investigation you've done so far. I've wondered when we'd first come up against a 32bit integer id issue. At a rough guess the `php artisan bookstack:copy-shelf-permissions --all` command will effectively delete and insert: ``` (number of shelves) x (number of roles) x (number of child books, chapters & pages within a shelf) x (~ 4 different permissions) ``` Can increase very quickly if the number of entities or roles is high in your instance, Then coupled with running that every hour. Still, 4 billion is a big number. I wonder if the way the batch operations cause MySQL to jump the id much further than expected. I've assigned this to be looked at for the next release. I'll check if the id value is really needed or look at changing the permission generation process & column type if it is needed.
Author
Owner

@Cidwill commented on GitHub (Jul 21, 2020):

Hi, has there been any news on this issue? We've recently had to add this command to our hourly Cron as we found that permissions were not copying shelves when books were made from within the shelf with the new book button.

@Cidwill commented on GitHub (Jul 21, 2020): Hi, has there been any news on this issue? We've recently had to add this command to our hourly Cron as we found that permissions were not copying shelves when books were made from within the shelf with the new book button.
Author
Owner

@ssddanbrown commented on GitHub (Jul 21, 2020):

Hi @Cidwill ,
That's a bit of a different issue (expecting permissions to copy down on child book creation) whereas this issue is focused to reaching database limits in the permission system.

@ssddanbrown commented on GitHub (Jul 21, 2020): Hi @Cidwill , That's a bit of a different issue (expecting permissions to copy down on child book creation) whereas this issue is focused to reaching database limits in the permission system.
Author
Owner

@Cidwill commented on GitHub (Jul 21, 2020):

You're absolutely correct. Consider that detail off topic (by attempting to add detail I put the horse before the cart).

I mentioned it because we are using the function mentioned as a workaround, and running it hourly also as the original poster was doing.

@Cidwill commented on GitHub (Jul 21, 2020): You're absolutely correct. Consider that detail off topic (by attempting to add detail I put the horse before the cart). I mentioned it because we are using the function mentioned as a workaround, and running it hourly also as the original poster was doing.
Author
Owner

@ssddanbrown commented on GitHub (Aug 4, 2020):

I've now pushed up a change to remove the old auto-incrementing primary key since it was not used. This will be part of v0.30.

@ssddanbrown commented on GitHub (Aug 4, 2020): I've now pushed up a change to remove the old auto-incrementing primary key since it was not used. This will be part of v0.30.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/BookStack#1707