Skip to content

Page revisions list can exhaust memory/query limits with high item counts #3633

@rockenren

Description

@rockenren

Attempted Debugging

  • I have read the debugging page

Searched GitHub Issues

  • I have searched GitHub for the issue.

Describe the Scenario

We have a page with 1000+ revisions in count (and 650 rows in database), when trying to access this page revisions history, the error occurs (see logs below).

image

We already increased PHP and Nginx memory limits, but it's not working anymore.
We are using Nginx + PHP 7.4 + MySQL from Ubuntu repos (5.7.38-0ubuntu0.18.04.1).

Exact BookStack Version

v22.07.2

Log Content

Nginx log:

2022/08/10 12:22:40 [error] 1523#1523: *3154 FastCGI sent in stderr: "PHP message: PHP Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 1126400 bytes) in /var/www/bookstack/vendor/laravel/framework/src/Illuminate/Database/Connection.php on line 373PHP message: PHP Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 2014 Cannot execute queries while other unbuffered queries are active. Consider using PDOStatement::fetchAll(). Alternatively, if your code is only ever going to run against mysql, you may enable query buffering by setting the PDO::MYSQL_ATTR_USE_BUFFERED_QUERY attribute. in /var/www/bookstack/vendor/laravel/framework/src/Illuminate/Database/Connection.php:368 Stack trace: #0 /var/www/bookstack/vendor/laravel/framework/src/Illuminate/Database/Connection.php(368): PDO->prepare() #1 /var/www/bookstack/vendor/laravel/framework/src/Illuminate/Database/Connection.php(705): Illuminate\Database\Connection->Illuminate\Database\{closure}() #2 /var/www/bookstack/vendor/laravel/framework/src/Illuminate/Database/Connection.php(672): Illuminate\Database\Connection->runQueryCallback() #3 /var/www/bookstack/vendor/laravel/framework/src/Illuminate/Database/Connection.php(376): Illuminate\Database\Connection->run() #4 /var/www/" while reading response header from upstream, client: <IP>, server: <SERVER>, request: "GET <URI>/revisions HTTP/2.0", upstream: "fastcgi://unix:/run/php/php7.4-fpm.sock:", host: "<HOST>", referrer: "<URL>" 2022/08/10 12:22:40 [error] 1523#1523: *3154 FastCGI sent in stderr: "PHP message: PHP Warning: Packets out of order. Expected 147 received 79. Packe" while reading upstream, client: <IP>, server: <HOST>, request: "GET <URI>/revisions HTTP/2.0", upstream: "fastcgi://unix:/run/php/php7.4-fpm.sock:", host: "<SERVER>", referrer: "<URL>" 2022/08/10 12:22:40 [error] 1523#1523: *3154 FastCGI sent in stderr: "t size=0 in Unknown on line 0" while reading upstream, client: <IP>, server: <SERVER>, request: "GET <URI>/revisions HTTP/2.0", upstream: "fastcgi://unix:/run/php/php7.4-fpm.sock:", host: "<HOST>", referrer: "<URL>"

laravel.log:

[stacktrace] #0 {main} "} [2022-08-10 12:22:40] production.ERROR: Allowed memory size of 268435456 bytes exhausted (tried to allocate 1126400 bytes) {"userId":3,"exception":"[object] (Symfony\\Component\\ErrorHandler\\Error\\FatalError(code: 0): Allowed memory size of 268435456 bytes exhausted (tried to allocate 1126400 bytes) at /var/www/bookstack/vendor/laravel/framework/src/Illuminate/Database/Connection.php:373)

PHP Version

7.4

Hosting Environment

Ubuntu 18.04.6 LTS, installed using official installation script.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions