FS#69726 - [nextcloud] Running occ command php fatal error

Attached to Project: Community Packages
Opened by Jonas Heinrich (onny) - Sunday, 21 February 2021, 09:29 GMT
Last edited by David Runge (dvzrv) - Tuesday, 23 February 2021, 11:10 GMT
Task Type Bug Report
Category Packages
Status Closed
Assigned To Sergej Pupykin (sergej)
David Runge (dvzrv)
Architecture All
Severity Low
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 6
Private No

Details

Description:
Since upgrading to Nextcloud 21 I get following error trying to run ./occ or any php file inside the Nextcloud directory:

$ 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

This bug occours with php8 and php7 :/ Somehow Nextcloud is running fine through php-fpm and Caddy as web frontend.

Additional info:
* package version(s): nextcloud 21.0.0-4
* config and/or log files etc. https://help.nextcloud.com/t/occ-command-php-fatal-error-allowed-memory-size-of-xxx-bytes-exhausted/108521
* link to upstream bug report, if any https://help.nextcloud.com/t/occ-command-php-fatal-error-allowed-memory-size-of-xxx-bytes-exhausted/108521

Would be happy if someone got some clues for debugging :)

Regareds
Jonas
This task depends upon

Closed by  David Runge (dvzrv)
Tuesday, 23 February 2021, 11:10 GMT
Reason for closing:  Fixed
Additional comments about closing:  The problem is related to php-apcu based caching. A warning has been added to the wiki:
https://wiki.archlinux.org/index.php/Nex tcloud#Using_the_ownCloud_console
Comment by David Runge (dvzrv) - Sunday, 21 February 2021, 09:55 GMT
@onny: Thanks for the report.

Please note, that the application now needs to be run as its own user (nextcloud).

Please check whether nextcloud >= 21.0.0-6 in [community-testing] fixes this for you.

NOTE: Please be aware, that that version also introduces other changes, that are necessary to fix the situation with the config directory [1] (basically reverting to pre 21.0.0 behavior in regards to location/ symlinking of the configuration).

[1] https://bugs.archlinux.org/task/69718#comment196955
Comment by David Runge (dvzrv) - Sunday, 21 February 2021, 13:08 GMT
@onny: Please refer to the relevant subsection in the troubleshooting section of the wiki article [1] for information on how to straighten out your setup.

[1] https://wiki.archlinux.org/index.php/Nextcloud#Issues_with_permissions_and_setup_after_upgrade_to_%3E=_21.0.0
Comment by Jonas Heinrich (onny) - Sunday, 21 February 2021, 17:08 GMT
Thank you @David for the packaging and the support :)
This one is really tricky ^^ Upgraded to 21.0.0-6 and /etc/webapps/nextcloud & /var/lib/nextcloud is now owned by the user and group nextcloud.
occ is still failing :(

root@http /u/s/w/nextcloud [255]# pwd
/usr/share/webapps/nextcloud
root@http /u/s/w/nextcloud# /usr/bin/occ
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

I also configured a php-fpm pool with the nextcloud user for the web server but it doesn't seem to work yet. Still figuring out. Nothing added to the nextcloud.log, only 404 in Caddy log trying to access / and no php errors :(
Comment by marlemion (marlemion) - Sunday, 21 February 2021, 18:26 GMT
I have a setup with a vhost using ssl and suexec (_not_ httpd). In the vhost, nextcloud resides in /nextcloud. I use this link in a _lot_ of clients. This 'security' feature seems to break my setup completely. It seems that I do not have another choice but

a) set up another vhost running suexec nextcloud and change the url in all places

b) use my own PKGBUILD from now on

or do I miss some other option?
Comment by David Runge (dvzrv) - Sunday, 21 February 2021, 20:53 GMT
@onny: It seems people have had weird problems with their php or php-fpm configs, which lead to some crash loop and php requiring too much memory. Try enabling extensions one by one.

@marlemion: If you don't have anything constructive to add to this specific ticket, please leave your remarks somewhere else. If you have a specific problem to discuss, open a ticket on your own, but please don't hijack other people's tickets.
Comment by Jonas Heinrich (onny) - Sunday, 21 February 2021, 21:54 GMT
Really good point! I tried to use the default php.ini without any other configuration in conf.d etc. So I had to reenable the database connector. After that occ results in the same error :(

In case it helps somehow, here is the output of php -i https://pastebin.com/mubcQy2p

But I really guess this is somehow related to an internal Nextcloud bug. There are other people with other systems having similar issues https://help.nextcloud.com/t/nextcloud-consuming-all-memory-and-swap-and-crashing-server/108532

Thinking about creating an upstream ticket :/

Still wondering why php-fpm had no issues rendering index.php etc. whereas php on the command line throws this error on every single php file inside Nextcloud directory :/
Comment by Sefa Eyeoglu (Scrumplex) - Sunday, 21 February 2021, 22:00 GMT
I suspect some kind of infinite loop here. Raising the memory limit in php.ini does not fix the issue, as it just takes longer to crash with more memory to fill.

I can add that the same issue occurs with cron.php.

PHP-FPM seems to work fine on my end, it's just with PHP CLI that this issue happens. It also seems to be specific to Nextcloud
Comment by Adrien Oliva (yapbreak) - Monday, 22 February 2021, 09:02 GMT
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)
Comment by Jonas Heinrich (onny) - Monday, 22 February 2021, 11:27 GMT Comment by David Runge (dvzrv) - Monday, 22 February 2021, 17:52 GMT
@onny: Given that I can not reproduce your issue and that you have now repeatedly used `sudo -u http php ./occ` in examples and also in the linked upstream bug report:
I just wanted to make sure, that you are aware of my first comment to this ticket [1] in which I mention the requirement for the application (and this also includes the occ command!) to be run as the nextcloud user.
As a convenience wrapper I have added the /usr/bin/occ script, which automatically calls /usr/share/webapps/nextcloud/occ with the correct user (but offers the possibility to override what/how /usr/share/webapps/nextcloud/occ is called using $NEXTCLOUD_USER, $NEXTCLOUD_PHP and $NEXTCLOUD_PHP_CONFIG).
This change is explained in detail in the wiki [2] now as well. However, the new occ wrapper script is not yet covered in the article.

[1] https://bugs.archlinux.org/task/69726#comment196963
[2] https://wiki.archlinux.org/index.php/Nextcloud#Issues_with_permissions_and_setup_after_upgrade_to_%3E=_21.0.0
Comment by Adrien Oliva (yapbreak) - Monday, 22 February 2021, 17:54 GMT
As far as I am concerned, I use `sudo -u nextcloud php ./occ` or your occ wrapper script. Result is the same!
Comment by Larry Meyer (ljflyaway82) - Monday, 22 February 2021, 18:04 GMT
I dont know anything about Caddy. But I received the same error message when trying to upgrade. No matter how many times I upped the memory in php.ini, the problem persisted.

You may not want to do this--- but what I had to do was do a new fresh install (all previous packages and dependencies deleted, including all folders left behind).

Once I did a fresh install of PHP 8 and nextcloud, and followed the guide closely, everything worked again.

Larry
Comment by David Runge (dvzrv) - Monday, 22 February 2021, 18:32 GMT
@yapbreak: Thanks for the confirmation!
This indeed points to some misconfiguration somewhere in the php.ini then I guess.
Sorry I can not be of much more help :-/
Comment by David Runge (dvzrv) - Monday, 22 February 2021, 18:36 GMT
Judging from an upstream bug report comment [1], it seems that we are not alone with this issue, so it is at least not Arch Linux or packaging specific (I hope!).

[1] https://github.com/nextcloud/server/issues/25742#issuecomment-783490277
Comment by Adrien Oliva (yapbreak) - Monday, 22 February 2021, 19:49 GMT
Seems to be an upgrade-only issue. Fresh install does not have this kind of "bug".

https://github.com/nextcloud/server/issues/25742#issuecomment-783553193
Comment by Jonas Heinrich (onny) - Tuesday, 23 February 2021, 06:58 GMT
Seems to be a configuration issue with php cli: https://github.com/nextcloud/server/issues/25742#issuecomment-783770628

Adding "apc.enable_cli=1" to php.ini solved it for me :)

Thanks to everyone for the support!

Loading...