Repository navigation
[NC 21] OCC Update error: allowed memory size exhausted #25742
Description
How to use GitHub
- Please use the 👍 reaction to show that you are affected by the same issue.
- Please don't comment if you have no relevant information to add. It's just extra noise for everyone subscribed to this issue.
- Subscribe to receive notifications on status change and new comments.
Steps to reproduce
- Upgrading to Nextcloud 21
- Run
php ./occin Nextcloud root directory ./occcrashes
Expected behaviour
Occ should work normally, for example printing available commands
Actual behaviour
Occ crashes with the following error:
$ sudo -u http ./occ update
PHP Warning: Module “gd” is already loaded in Unknown on line 0
PHP Fatal error: Allowed memory size of 536870912 bytes exhausted (tried to allocate 20480 bytes) in /usr/share/webapps/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php on line 133
To be more precise, this also happens running php cli against other files of Nextcloud, for example index.php or console.php.
Surprisingly Nextcloud is running fine through php-fpm and web server. It was even able to perform the upgrade to v21 just fine.
Another user commented on the ArchLinux bug tracker:
If it could help, I added a trace in /usr/share/webapps/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php on line 133, and I get in an infinite loop the following messages:
Could not resolve OC\User\Manager!
Could not resolve OC\Security\CSRF\CsrfTokenManager!As if it was unable to locate its lib/private/ folder.
If I set memory_limit to -1, it fill completely memory and hit OOMkiller.
(tried with both php7 and php8, with nextcloud-21.0.0-7)
Possibly not only related to ArchLinux setups. An other user reported the exact issue here, which was triggered on a Ubuntu installation.
Server configuration
Operating system: Archlinux x64
Web server: Caddy 2
Database: Mysql
PHP version: 8.0.2
Nextcloud version: (see Nextcloud admin page) 21.0.0
Updated from an older Nextcloud/ownCloud or fresh install: Yes
Where did you install Nextcloud from: Package repository
Signing status:
Signing status
Unable to access for now
List of activated apps:
App list
accessibility/ drawio/ files_trashbin/ nextcloud_announcements/ settings/ twofactor_gateway/
activity/ encryption/ files_versions/ notes/ sharebymail/ updatenotification/
admin_audit/ extract/ files_videoplayer/ notifications/ spreed/ user_ldap/
apporder/ federatedfilesharing/ firstrunwizard/ oauth2/ support/ user_status/
calendar/ federation/ integration_discourse/ password_policy/ survey_client/ viewer/
cloud_federation_api/ files/ integration_github/ photos/ suspicious_login/ weather_status/
comments/ files_ebookreader/ integration_reddit/ polls/ systemtags/ workflowengine/
contacts/ files_external/ integration_twitter/ privacy/ tasks/
contactsinteraction/ files_pdfviewer/ keeweb/ provisioning_api/ text/
dashboard/ files_rightclick/ logreader/ recommendations/ theming/
dav/ files_sharing/ lookup_server_connector/ serverinfo/ twofactor_backupcodes/
Nextcloud configuration:
Config report
<?php
$CONFIG = array (
'instanceid' => '****',
'datadirectory' => '/var/lib/nextcloud/data',
'dbtype' => 'mysql',
'version' => '21.0.0.18',
'dbname' => 'nextcloud',
'dbhost' => 'mysql.pi',
'mysql.utf8mb4' => true,
'dbuser' => 'nextcloud',
'dbpassword' => '****',
'installed' => true,
'maintenance' => false,
'loglevel' => 0,
'cron_log' => true,
'maxZipInputSize' => 5145728000,
'allowZipDownload' => true,
'memcache.local' => '\\OC\\Memcache\\APCu',
'allow_local_remote_servers' => true,
'trusted_domains' =>
array (
0 => 'nextcloud.****.org',
),
'passwordsalt' => '***',
'secret' => '****',
'mail_domain' => '******.org',
'mail_smtpmode' => 'php',
'mail_from_address' => 'nextcloud',
'trashbin_retention_obligation' => 'auto',
'updatechecker' => false,
'app.mail.verify-tls-peer' => false,
'overwrite.cli.url' => 'https://nextcloud.***.org',
'default_phone_region' => 'DE',
);
Are you using external storage, if yes which one: None, had configured SFTP mount point
Are you using encryption: No
Are you using an external user-backend, if yes which one: No
Client configuration
Browser: Latest Firefox
Operating system: NixOS
Nextcloud log (data/nextcloud.log)
Nextcloud log
[...]
{"reqId":"pti6pSFymOb7PvbzzzmM","level":0,"time":"2021-02-21T18:08:04+00:00","remoteAddr":"2****","user":"--","app":"files_sharing","method":"GET","url":"/cron.php","message":"/appinfo/app.php is deprecated, use \\OCP\\AppFramework\\Bootstrap\\IBootstrap on the application class instead.","userAgent":"Mozilla/5.0 (X11; Linux x86_64; rv:75.0) Gecko/20100101 Firefox/75.0","version":"21.0.0.18"}
{"reqId":"pti6pSFymOb7PvbzzzmM","level":0,"time":"2021-02-21T18:08:04+00:00","remoteAddr":"*****","user":"--","app":"keeweb","method":"GET","url":"/cron.php","message":"/appinfo/app.php is deprecated, use \\OCP\\AppFramework\\Bootstrap\\IBootstrap on the application class instead.","userAgent":"Mozilla/5.0 (X11; Linux x86_64; rv:75.0) Gecko/20100101 Firefox/75.0","version":"21.0.0.18"}
{"reqId":"pti6pSFymOb7PvbzzzmM","level":0,"time":"2021-02-21T18:08:04+00:00","remoteAddr":"*****","user":"--","app":"onlyoffice","method":"GET","url":"/cron.php","message":"/appinfo/app.php is deprecated, use \\OCP\\AppFramework\\Bootstrap\\IBootstrap on the application class instead.","userAgent":"Mozilla/5.0 (X11; Linux x86_64; rv:75.0) Gecko/20100101 Firefox/75.0","version":"21.0.0.18"}
Activity
dschrempf commentedon Feb 22, 2021
I am also affected by this. I run Arch Linux. I even tried a fresh install (but old data directory). The web interface works as expected.
kde35 commentedon Feb 22, 2021
I also run Arch Linux, and in the web interface, of O go to the page admin/overview, it says, among other things
Last background job execution ran 9 days ago. Something seems wrong. Check the background job settingsAnd if go to settings/admin#backgroundjobs I see that the choice "cron" is checked, and if try to check webcron or ajax, and leave the page to come back, cron is still checked. So even the webinterface doesn't work correctly.
tbasilici commentedon Feb 22, 2021
debian 10 here, same issue: tried with php 7.0 7.3 and 8.0 no joy, this is a nextcloud issue not an operative system one...
I upgraded from 21.0.0 RC2 to 21.0.0 and the issue presented itself on the upgrade at the end of the update process (that is the first time occ is run AFTER the files changed from rc2 to stable), this suggests me the problem might be somewhere in the changelog between the rc2 and the production ?
kde35 commentedon Feb 22, 2021
As a matter of fact, there are whole bunch of things that don't work with web interface. I can't update, enable, disable, remove or download applications.
onny commentedon Feb 22, 2021
As it might be relevant, here is some info about the php cli configuration:
php -i
st3iny commentedon Feb 22, 2021
I can reproduce this bug with Nextcloud stable21 and php v7.4 on Arch Linux.
Another finding: The occ command works fine if the instance is not yet installed. After installing (e.g. using web installer or occ install command) it becomes unusable.
onny commentedon Feb 22, 2021
Currently I suspect the upgrade process somehow corrupted the Mysql database?
I get following erros from the mysql/mariadb daemon:
InnoDB: Page [...] log sequence number [...] is in the future!
If I stop the database, occ runs until connection timeout to Mysql server. So my guess is Occ crashes after connecting to the database ...
onny commentedon Feb 22, 2021
Okay maybe it is something different. Nevertheless I put this at line 133 in
lib/private/AppFramework/Utility/SimpleContainer.php:Which is giving me this stack trace showing some kind of iteration with arrays including the PHP environment and configuration array?! https://onny.project-insanity.org/files/stacktrace_short.txt
Information which might be useful in this case:
/etc/webapps/nextcloud/config/config.php./usr/share/webapps/nextcloud/configis a symlink to the config folder located in/etc/webapps-folder/var/lib/nextcloud/dataonny commentedon Feb 22, 2021
This is what I get from logging mysql queries:
Nothing more ...
Edit: oc_appconfig has a lot of keys so I don't know where to look at. In case some value in there is causing the issue ...
Temtaime commentedon Feb 22, 2021
I hit OOM when upgrading to latest nextcloud by running occ upgrade.
Is there any workaround or fix?
st3iny commentedon Feb 22, 2021
I second this. I have been testing using the stable21 branch last week and it worked fine until a couple days ago. The regression was introduced recently.
Maybe bisecting from 21RC2 to the current version is a good starting point.
Xiretza commentedon Feb 22, 2021
Same issue here. Arch Linux ARM, but with Postgres backend, so it might not be related to mysql at all.
occattempts to allocate a lot more memory on startup than usual on 21.0.0, I tried increasingmemory_limitinphp.inibut that just causes it to get oomkilled at some point.Disabling all extensions except for
pgsqlandpdo_pgsql(without these twooccjust crashes) still results in the same behaviour.php -i
yapbreak commentedon Feb 22, 2021
Even with
memory_limitset to-1(so no limit at all),occwill fail and trigger OOMKiller on my server with 32GiB RAM and 32GiB Swap…83 remaining items
hrsto commentedon May 25, 2021
In my particular case it eats all memory and forces me to kill the php process. I did disable the accessibility app and set loglevel to 2, but when i start the update process again, it resets loglevel back to 0 and screws up again.
makuser commentedon May 25, 2021
Have you checked your APC/Redis cache setting, libraries and server?
hrsto commentedon May 25, 2021
nextcloud instance itself runs in its own container by itself. Redis and the database are in a different container. The nextcloud container is the one that has the memory leak. Haven't checked libraries - do you have any specific ones in mind (fyi, i'm not experienced with php)?
Since it's a personal cloud server that i've already backed up, i tried this workaround #25742 (comment) and so far everything seems to be in order.
makuser commentedon May 25, 2021
In my case changing the nextcloud loglevel absolutely nothing. I removed the php-redis package/library by mistake, which led to nextcloud being unable to use said caching service. Reinstalling that library fixed it. Removing it broke it again. Switching to memcache by installing the daemon and php libraries and changing the nextcloud config appropriately fixed it, removing the libraries/package broke it again.
So in my case it was all dependent on the nextcloud cache interface.
And sure, it's nextcloud that blows up, not any other service. So it absolutely makes sense that the nexcloud container is the one that dies, if you are using a containerized setup.
That is why I recommended to check your cache settings and your installed php libraries in your nextcloud container.
KoganeNoKenshi commentedon May 27, 2021
Installing php7.4-xml and php8.0-xml fixed it for me.
RealSnoopyDog commentedon May 27, 2021
This is not a fix for the real problem, it is a workaround (like all other hints)
apache/php: enable acpu cache/accelerator for php CLI
lars-becker commentedon Jun 4, 2021
I haven't had this problem until NC 22 Beta 3. Now I have the same error. Removing solves APCu resolves the problem but is not in line with the recommendations in the adminstration manual.
nextcloud: fixes 'allowed memory size exhausted' during nextcloud upg…
nextcloud: fixes 'allowed memory size exhausted' during nextcloud upg…
chriscroome commentedon Feb 15, 2022
Posting this here in case it helps anyone else...
You can check the PHP memory limit using the command line like this:
With the above defaults I was unable to upgrade Nextcloud:
php updater/updater.phar --no-backup ... PHP Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 167968632 bytes) in phar:///home/cloud/sites/nextcloud/updater/updater.phar/lib/Updater.php on line 637However after creating a
~/.php.inifile containing:And then running the update using this ini file:
php --php-ini ~/.php.ini updater/updater.phar --no-backupThere isn't a problem with the updater.
As far as I can tell you don't need to enable the OPCache or APCu for the CLI, the upgrade works for me with these settings:
lionants02 commentedon Feb 21, 2022
I'm using PHP CLI param
-d memory_limit=4096MWork for me.
Nextcloud version 21.0.3
I'm docker.
How to
STEP 1
'loglevel' => 2,STEP 2 run command wow!!
STEP 1
STEP 2
AlfaVila commentedon Feb 7, 2023
sudo --u www-data php --define memory_limit=512M /var/www/html/occ files:scan --all