NextCloud memory limit


(Wayne Bilger) #1

I am getting the folloing error when trying to run a occ files:scan in nextcloud on my NS.

PHP Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 72 bytes) in /var/www/html/nextcloud/lib/private/Lock/DBLockingProvider.php on line 263

I am running NextCloud 11.0.2 stable.
I can limit the files:scan to specific folders and in completes no problem, but I have over 320000 files.
Can I increase the php memory limit on NS? If so, how, and can I safely do so?
My NS is running in VirtualBox, and has 8GB allocated.
I found this topic to edit it php.ini, but not sure how I would go about changing the memory_limit.

(Marc) #2

You can try from the command line with:

config setprop php MemoryLimit 256
signal-event nethserver-php-save
apachectl restart

If it does not work, then we may have to look if the db property isn’t applied to the php 5.4 (used for Nextcloud) that lives under /opt

(Wayne Bilger) #3

Nextcloud 11 uses php 5.6.
Would I specify the php version, like;

config setprop /opt/rh/rh-php56/root/bin/php MemoryLimit 256

I tried it, and seemed to return with no error, but nethserver-php-save returns with error, but nethserver-php-update works.
But, I assume it updates php 5.4, and what command would I run to udpate php 5.6?
If I run “config setprop php MemoryLimit 256” it seems to work and update, but I have no way to check “config setprop /opt/rh/rh-php56/root/bin/php MemoryLimit 256” worked. “db configuration show php” returns configuration of php 5.4.

(Marc) #4

Sorry, meant php5.6 but didn’t recall correctly.

Cannot access any test server right now, but if php-save is not there then it might be:

signal-event nethserver-php-update

Setting config setprop /opt/rh/rh-php56/root/bin/php MemoryLimit 256 won’t work.

For php5.6 there is a nethserver-rh-php56-php-fpm-update event.

Will test it late night.

(Wayne Bilger) #5

Yes, “signal-event nethserver-php-update”, I had updated my post above.

If “config setprop /opt/rh/rh-php56/root/bin/php MemoryLimit 256” won’t work, how do I update php 5.6, or do they use the same config?

(Wayne Bilger) #6

I still get the exact same error after increasing php MemoryLimit to 256, so I assume it udpates php 5.4, and not 5.6.
How would I update MemoryLimit for php 5.6?

(Marc) #7

Just looked at it and the default memory limit for Nextcloud is set to 512MB. You can verify it in Nextcloud’s server info page.

The error refers to /var/www/html/nextcloud/lib/private/Lock/DBLockingProvider.php on line 263, but the path is no longer valid as Nextcloud files were moved under /usr/share/nextcloud.

(Marc) #8

How is the occ command called?

sudo -u apache /opt/rh/rh-php56/root/usr/bin/php /usr/share/nextcloud/occ files:scan --all

(Wayne Bilger) #9

Yes, except I just did for 1 user,

sudo -u apache /opt/rh/rh-php56/root/usr/bin/php /usr/share/nextcloud/occ files:scan -v username

A partial scan is run before the error, and I can limit it with the --path command and the command completes ok.

(Marc) #10

Can you share the output of:

rpm -qa *nextcloud*

and check if there’s anything left under /var/www/html/nextcloud, as it seems something is strangely mixed up.

(Wayne Bilger) #11

'#rpm -qa nextcloud


/var/www/html/nextcloud directory does not exist

(Marc) #12

That’s ok.
Don’t know why the error reports something from /var/www/html/nextcloud.

  • Does Nextcloud logs show additional errors after running the occ files:scan command (eg. locked files, etc.)?
  • Have you customized .htaccess, config.php or virtual hosts for nextcloud?

PS: sorry to ask many questions, just trying to figure out what happened.

(Wayne Bilger) #13

I get nothing written to the nextcloud log files when a scan run, is there somewhere else I could look?
I have all options turned on in the logging in admin.
This still feels like a memory issue to me, I can scan smaller directories of the file structure without error, but if I try to do all (316946 files) I get the memory error, and if I try very large directory (204061 files) same memory error but it stops after a different number of files and subdirectories. I was hoping they would stop at the same file, and maybe it was a corrupt file causing the issue, but that doesn’t seem to be the case.
I don’t understand why the log file doesn’t show info about the scan, there must be another log other than nextcloud.log?

I have not made any customizations.

(Marc) #14

Please, check if this command returns empty:

grep -ri '/var/www/html/nextcloud' /etc/httpd/

Back to the memory issue:

  • How much memory is reported on Nextcloud’s admin server info page?
  • What is the output of the following commands:

(Wayne Bilger) #15



Version: 5.6.25

Memory Limit: 512.0 MB

Max Execution Time: 3600

Upload max size: 511.0 MB

memory_limit => 128M => 128M
PHP Warning: Unknown: It is not safe to rely on the system’s timezone settings. You are required to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected the timezone ‘UTC’ for now, but please set date.timezone to select your timezone. in Unknown on line 0

/etc/opt/rh/rh-php56/php-fpm.d/www.conf:;php_admin_value[memory_limit] = 128M
/etc/opt/rh/rh-php56/php.ini:memory_limit = 128M

grep: /usr/share/nextcloud/.: Is a directory
grep: /usr/share/nextcloud/…: Is a directory
/usr/share/nextcloud/.htaccess: php_value memory_limit 512M
/usr/share/nextcloud/.htaccess: php_value memory_limit 512M

(Marc) #16

You can try to adjust memory_limit near line 396 of /etc/opt/rh/rh-php56/php.ini

…or run the occ command overriding the php memory limit:

sudo -u apache /opt/rh/rh-php56/root/usr/bin/php -d memory_limit=512M /usr/share/nextcloud/occ files:scan -v username

How to implement Elasticsearch in Nexcloud
(Wayne Bilger) #17

So, changing that from 128M to 256 works! Is that change permanent, or will that be something that gets overwritten when there is an update?
So, although nextcloud reports 512M, line 396 of /etc/opt/rh/rh-php56/php.ini says

; Maximum amount of memory a script may consume (128MB)
memory_limit = 256M (I changed this from 128M)

(Marc) #18

If I got it right, the 512MB reported by Nextcloud are set using a .user.ini file in the nextcloud directory that effectively overrides the value set in php.ini, just for the nextcloud context.
The 128MB are set globally for php5.6, and that’s what the php command line uses when directly called.

Don’t know if an update will override the changes. @giacomo might be able to give us some hints about this :wink:

(Giacomo Sanchietti) #19

@wbilger you can change the php.ini without problem, since the files is marked as configuration file and there is no template which can overwrite it.

Do you think we need to add some new props to handle this special cases?

IMO, I’d like to don’t add anything and let the user manually edit the config file.

(Wayne Bilger) #20

Thanks, and thanks @dnutan for all you help.
I have no problem editing a config file, especially if this is a rare case. I’m not sure if
I get the error because of corrupt file, or odd filename during the scan, or if it is the number of files that are being scanned. 320000 files does not really seem like it is extraordinarily high to me.