[SOLVED] Nextcloud 16.0.7 / 17.0.2 php cron.php => Out of Memory

Support intro

Sorry to hear you’re facing problems :slightly_frowning_face:

help.nextcloud.com is for home/non-enterprise users. If you’re running a business, paid support can be accessed via portal.nextcloud.com where we can ensure your business keeps running smoothly.

In order to help you as quickly as possible, before clicking Create Topic please provide as much of the below as you can. Feel free to use a pastebin service for logs, otherwise either indent short log examples with four spaces:

example

Or for longer, use three backticks above and below the code snippet:

longer
example
here

Some or all of the below information will be requested if it isn’t supplied; for fastest response please provide as much as you can :heart:

Nextcloud version (eg, 12.0.2): 16.0.7 and 17.0.2.1
Operating system and version (eg, Ubuntu 17.04): Devuan ASCII (= 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.3.13-1+0~20191218.50+debian9~1

The issue you are facing:

PHP Fatal error:  Allowed memory size of 671088640 bytes exhausted (tried to allocate 20480 bytes) in /var/www/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php on line 80
PHP Fatal error:  Allowed memory size of 671088640 bytes exhausted (tried to allocate 20480 bytes) in /var/www/nextcloud/lib/private/Log/File.php on line 125

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

Steps to replicate it:

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

Some PHP details:

php -ini:

root@wolke7:/var/www/nextcloud/config# php -ini
phpinfo()
PHP Version => 7.3.13-1+0~20191218.50+debian9~1.gbp23c2da

System => Linux wolke7 4.9.0-6-amd64 #1 SMP Debian 4.9.88-1+deb9u1 (2018-05-07) x86_64
Build Date => Dec 18 2019 15:03:24
Server API => Command Line Interface
Virtual Directory Support => disabled
Configuration File (php.ini) Path => /etc/php/7.3/cli
Loaded Configuration File => /etc/php/7.3/cli/php.ini
Scan this dir for additional .ini files => /etc/php/7.3/cli/conf.d

php memory limits for cli:
root@wolke7:/var/www/nextcloud/config# php -i | grep memory_limit
memory_limit => 640M => 640M

php memory limits for FPM:
root@wolke7:/etc/php/7.3/fpm# grep memory_limit php.ini
memory_limit = 640M

top during cron.php execution just before Exit 255 Out of memory:

top - 11:12:16 up  1:25,  2 users,  load average: 0.68, 0.32, 0.18
Tasks: 181 total,   2 running, 179 sleeping,   0 stopped,   0 zombie
%Cpu(s): 43.8 us,  3.5 sy,  0.0 ni, 49.7 id,  0.0 wa,  0.0 hi,  3.0 si,  0.0 st
KiB Mem :  4050816 total,  1467784 free,   820140 used,  1762892 buff/cache
KiB Swap:  3906556 total,  3906556 free,        0 used.  2836004 avail Mem 

  PID USER      PR  NI    VIRT    RES    SHR S  %CPU %MEM     TIME+ COMMAND                                                                 
 1017 postgres  20   0  704484  17180  14348 S  64.5  0.4   0:15.70 postgres                                                                
 1016 www-data  20   0 1030568 715124  27960 R  35.2 17.7   0:08.63 php                                                                     
  749 www-data  20   0 1545644   7404   5016 S   0.3  0.2   0:00.04 apache2                                                                 
 2090 postgres  20   0  703072  37020  35076 S   0.3  0.9   0:00.22 postgres                                                                
 6720 os        20   0  108888   4304   3180 S   0.3  0.1   0:00.19 sshd                                                                    
    1 root      20   0   15792   1884   1728 S   0.0  0.0   0:00.44 init                                                                    
    2 root      20   0       0      0      0 S   0.0  0.0   0:00.00 kthreadd                

The output of your config.php file in /path/to/nextcloud (make sure you remove any identifiable information!):

<?php
$CONFIG = array (
  'instanceid' => 'ocky83h4wem7',
  'passwordsalt' => 'XXX',
  'secret' => 'XXX',
  'trusted_domains' => 
  array (
    0 => 'wolke7.XXX',
  ),
  'datadirectory' => '/mnt/usb-cloud/data',
  'dbtype' => 'pgsql',
  'version' => '16.0.7.1',
  'overwrite.cli.url' => 'https://wolke7.XXX/nxc',
  'dbname' => 'db_nextcloud',
  'dbhost' => 'localhost',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'dbuser' => 'u_nextcloud',
  'dbpassword' => 'XXX',
  'installed' => true,
  'theme' => '',
  'loglevel' => 2,
  'maintenance' => false,

  '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',

  'htaccess.RewriteBase' => '/nxc',

  'cache_path' => '/mnt/cloud-cache',

  'default_language' => 'de',

);

I do get the same behaviour if I switch from php7.3 to php7.2 or vice versa. I do get the same errors when switch between Nextcloud versions 16.0.7 and 17.0.2.1when executing cron.php.

Nextcloud itself seems to work fine, just the cron errors remain.

Any ideas/hints/tests are more than welcome.

Thanks, -MN

This turned out to be a PostgreSQL database issue (corrupt database/table/index).

Search in

/var/log/postgresql/postresql-9.6-main.log

for entries like

2020-01-07 13:36:15.599 EST [15852] ERROR:  MultiXactId 1583362 has not been created yet -- apparent wraparound
2020-01-07 13:36:15.599 EST [15852] CONTEXT:  automatic analyze of table "db_nextcloud.public.oc_jobs"

My solution was to use a new database, reinstall from scratch and use

root@wolke7:/var/www/nextcloud# sudo -u www-data php /var/www/nextcloud/occ files:scan --all

to populate the database again.

Thanks, -MN

1 Like