Nextcloud 17.0.2.1 cron.php Out of Memory error with php7.2-fpm

Nextcloud version (eg, 12.0.2): 17.0.2.1
Operating system and version (eg, Ubuntu 17.04): Devuan ASCII x86 64bit (= Debian 9 /wo systemd)
Apache or nginx version (eg, Apache 2.4.25): Apache 2.4.25-3+deb9u9
PHP version (eg, 7.1): 7.2.26-1+0-20191218.33+debian9
SQL-Server: PostgreSQL 9.6+181+deb9u3

The issue you are facing:

  Error   PHP       Out of memory (allocated 2097152) (tried to allocate 20480 bytes) at                                         2020-01-06T07:52:10+00:00  
                    /var/www/nextcloud/3rdparty/symfony/routing/RouteCompiler.php#225                                                                       
                                                                                                                                                            
  Error   PHP       Out of memory (allocated 5962203136) (tried to allocate 20480 bytes) at                                      2020-01-06T07:52:28+00:00  
                    /var/www/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/SQLParserUtils.php#209                                                      

System has 4GB RAM and 4 GB swap space. PHP-FPM is using all of it.

root@wolke7:/etc/php/7.2/fpm# grep memory_limit php.ini 
memory_limit = 512M

System worked fine for 2-3 months until this error showed up (no updates added). System worked fine with Nextcloud 16.XX and PHP7.3, problems happened some time after upgrade to 17.0.1. Tried downgrading from PHP7.3 to PHP7.2 - no solution.

Is this the first time you’ve seen this error? (Y/N): N

Steps to replicate it:

  1. sudo -u www-data /var/www/nextcloud/cron.php

The output of your Nextcloud log in Admin > Logging:

{"reqId":"wrDwlgCu2OSCvDYKYbW2","level":3,"time":"2020-01-06T09:01:12+00:00","remoteAddr":"192.168.255.100","user":"oliver","app":"no app in context","method":"GET","url":"/nxc/ocs/v2.php/core/navigation/apps?absolute=true&format=json","message":{"Exception":"Doctrine\\DBAL\\Exception\\DriverException","Message":"An exception occurred while executing 'SELECT \"id\" FROM \"oc_jobs\" WHERE (\"class\" = ?) AND (\"argument\" = ?) LIMIT 1' with params [\"OCA\\\\QuotaWarning\\\\Job\\\\User\", \"{\\\"uid\\\":\\\"oliver\\\"}\"]:\n\nSQLSTATE[XX000]: Internal error: 7 ERROR:  MultiXactId 1583362 has not been created yet -- apparent wraparound","Code":0,"Trace":[{"file":"/var/www/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/DBALException.php","line":169,"function":"convertException","class":"Doctrine\\DBAL\\Driver\\AbstractPostgreSQLDriver","type":"->","args":["An exception occurred while executing 'SELECT \"id\" FROM \"oc_jobs\" WHERE (\"class\" = ?) AND (\"argument\" = ?) LIMIT 1' with params [\"OCA\\\\QuotaWarning\\\\Job\\\\User\", \"{\\\"uid\\\":\\\"oliver\\\"}\"]:\n\nSQLSTATE[XX000]: Internal error: 7 ERROR:  MultiXactId 1583362 has not been created yet -- apparent wraparound",{"errorInfo":["XX000",7,"ERROR:  MultiXactId 1583362 has not been created yet -- apparent wraparound"],"__class__":"Doctrine\\DBAL\\Driver\\PDOException"}]},{"file":"/var/www/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/DBALException.php","line":145,"function":"wrapException","class":"Doctrine\\DBAL\\DBALException","type":"::","args":[{"__class__":"Doctrine\\DBAL\\Driver\\PDOPgSql\\Driver"},{"errorInfo":["XX000",7,"ERROR:  MultiXactId 1583362 has not been created yet -- apparent wraparound"],"__class__":"Doctrine\\DBAL\\Driver\\PDOException"},"An exception occurred while executing 'SELECT \"id\" FROM \"oc_jobs\" WHERE (\"class\" = ?) AND (\"argument\" = ?) LIMIT 1' with params [\"OCA\\\\QuotaWarning\\\\Job\\\\User\", \"{\\\"uid\\\":\\\"oliver\\\"}\"]:\n\nSQLSTATE[XX000]: Internal error: 7 ERROR:  MultiXactId 1583362 has not been created yet -- apparent wraparound"]},

The output of yourconfig.php:

<?php
$CONFIG = array (
  'instanceid' => 'XXXXXXXXXXXXXXXX',
  'passwordsalt' => 'XXXXXXXXXXXXXXXXXXX',
  'secret' => 'XXXXXXXXXXXXXXXXXXXX',
  'trusted_domains' => 
  array (
    0 => 'wolke7.XXXXXXXXXXXXXXXXXXXXX',
    1 => 'wolke7-ext.XXXXXXXXXXXXXXXXXXXXXXXXX',
  ),
  'datadirectory' => '/mnt/usb-cloud/data',
  'dbtype' => 'pgsql',
  'version' => '17.0.2.1',
  'overwrite.cli.url' => 'https://wolke7.XXXXXXXXXXXXXXXXXXX/nxc/',
  'dbname' => 'db_nextcloud',
  'dbhost' => 'localhost',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'dbuser' => 'XXXXXXXXXXXXXXXXXXXXXX',
  'dbpassword' => 'XXXXXXXXXXXXXXXXXXX',
  'installed' => true,
  'memcache.local' => '\\OC\\Memcache\\APCu',
  'memcache.distributed' => '\\OC\\Memcache\\Redis',
  'redis' => 
  array (
    'host' => '/var/run/redis/redis.sock',
    'port' => 0,
    'timeout' => 0.0,
  ),
  'filelocking.enabled' => true,
  'memcache.locking' => '\\OC\\Memcache\\Redis',
  'maintenance' => false,
  'theme' => '',
  'loglevel' => 2,
  'htaccess.RewriteBase' => '/nxc',
  'cache_path' => '/mnt/cloud-cache',
  'default_language' => 'de',
  'app_install_overwrite' => 
  array (
    0 => 'groupfolders',
  ),
  'updater.secret' => '$2XXXXXXXXXXXXXXXXXXXXXXXXJzyC',
);

The output of your Apache/nginx/system log in /var/log/____:

PASTE HERE

[EDIT] Just disabled all 3rd Party Apps and only enabled Official ones. No change.

I ran into a similar issue where my server was crashing due to an out_of_memory issue.

What I did find is that one of the External Storage shares that I had configured was causing an error with the background update task. This causes the NextCloud cron job to get stuck and keep consuming memory until the server ran out and crashed.

After removing the external storage that was causing issues, I saw a major drop in resource usage.