Large file downloads stop at 2.1GB

Canā€™t download large movie files. Download stops at about 2.1GB, regardless of file size.

Also, unable to update NextcloudPi to latest version. These seem to be related problems, as they started when I was going through several upgrades a couple months ago.

Any help appreciated, and Iā€™ll supply more info as needed, but Iā€™m not familiar with the procedure to generate some of the logs and outputs mentioned in the support form. Thank you.

Nextcloud version (eg, 20.0.5): v1.52.4

Operating system and version (eg, Ubuntu 20.04): Armbian 23.8.1 bullseye

Apache or nginx version (eg, Apache 2.4.25): Not familiar with procedure to determine Apache version

PHP version (eg, 7.4): 8.0.30

The issue you are facing:

Large file downloads stop at about 2.1GB.

Also unable to update the server to more recent version of NextcloudPi

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

Steps to replicate it:

1. Log in

2. Attempt to download a large movie file

3. Download stops at 2GB regardless of how much larger it is

The output of your Nextcloud log in Admin > Logging:


Typical failure error:

**[PHP] Error: file_put_contents(): content truncated from 2527498122 to 2147483647 bytes at /var/www/nextcloud/lib/private/Files/Storage/Local.php#313**

**MOVE /remote.php/dav/uploads/Dan/1858936242/.file**

**from 192.168.1.213 by User at 2024-01-02T00:10:51+00:00**

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


***Not familiar with the procedure to generate this output***

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


***Not familiar with the procedure to generate this output***

PASTE HERE


Output errors in nextcloud.log in /var/www/ or as admin user in top right menu, filtering for errors. Use a pastebin service if necessary.

***Error log file is almost 100MB, so I will copy several recent and typical errors. More can be provided upon request.***

[PHP] Error: file_put_contents(): content truncated from 2527498122 to 2147483647 bytes at /var/www/nextcloud/lib/private/Files/Storage/Local.php#313

MOVE /remote.php/dav/uploads/User/1858936242/.file

from 192.168.1.213 by User at 2024-01-02T00:10:51+00:00

[core] Error: Renewing session token failed

GET /settings/admin/logging

from 192.168.1.165 at 2023-12-26T20:40:41+00:00

[remote] Error: RedisException: No such file or directory at <<closure>>

0. /var/www/nextcloud/lib/private/RedisFactory.php line 137

Redis->pconnect()

1. /var/www/nextcloud/lib/private/RedisFactory.php line 178

OC\RedisFactory->create("*** sensitive parameters replaced ***")

2. /var/www/nextcloud/lib/private/Memcache/Redis.php line 66

OC\RedisFactory->getInstance()

3. /var/www/nextcloud/lib/private/Memcache/Redis.php line 72

OC\Memcache\Redis->getCache()

4. /var/www/nextcloud/lib/private/App/InfoParser.php line 58

OC\Memcache\Redis->get()

5. /var/www/nextcloud/lib/private/App/AppManager.php line 506

OC\App\InfoParser->parse()

6. /var/www/nextcloud/lib/private/legacy/OC_App.php line 607

OC\App\AppManager->getAppInfo()

7. /var/www/nextcloud/lib/private/AppFramework/App.php line 71

OC_App::getAppInfo()

8. /var/www/nextcloud/lib/private/legacy/OC_App.php line 291

OC\AppFramework\App::buildAppNamespace()

9. /var/www/nextcloud/lib/private/AppFramework/Bootstrap/Coordinator.php line 119

OC_App::registerAutoloading()

10. /var/www/nextcloud/lib/private/AppFramework/Bootstrap/Coordinator.php line 90

OC\AppFramework\Bootstrap\Coordinator->registerApps()

11. /var/www/nextcloud/lib/base.php line 694

OC\AppFramework\Bootstrap\Coordinator->runInitialRegistration()

12. /var/www/nextcloud/lib/base.php line 1171

OC::init()

13. /var/www/nextcloud/status.php line 37

require_once("/var/www/nextcloud/lib/base.php")

GET /status.php

from 192.168.1.165 at 2023-12-26T01:05:09+00:00

UPDATE NEXTCLOUDPI output:

[ nc-update ] (Tue Dec 26 20:33:20 UTC 2023)
Downloading updates
Performing updates
An unhandled exception has been thrown:
Doctrine\DBAL\Exception: Failed to connect to the database: An exception occurred in the driver: could not find driver in /var/www/nextcloud/lib/private/DB/Connection.php:140
Stack trace:
#0 /var/www/nextcloud/3rdparty/doctrine/dbal/src/Connection.php(1531): OC\DB\Connection->connect()
#1 /var/www/nextcloud/3rdparty/doctrine/dbal/src/Connection.php(1029): Doctrine\DBAL\Connection->getWrappedConnection()
#2 /var/www/nextcloud/lib/private/DB/Connection.php(262): Doctrine\DBAL\Connection->executeQuery()
#3 /var/www/nextcloud/3rdparty/doctrine/dbal/src/Query/QueryBuilder.php(345): OC\DB\Connection->executeQuery()
#4 /var/www/nextcloud/lib/private/DB/QueryBuilder/QueryBuilder.php(280): Doctrine\DBAL\Query\QueryBuilder->execute()
#5 /var/www/nextcloud/lib/private/AppConfig.php(418): OC\DB\QueryBuilder\QueryBuilder->execute()
#6 /var/www/nextcloud/lib/private/AppConfig.php(184): OC\AppConfig->loadConfigValues()
#7 /var/www/nextcloud/lib/private/AppConfig.php(374): OC\AppConfig->getApps()
#8 /var/www/nextcloud/lib/private/legacy/OC_App.php(976): OC\AppConfig->getValues()
#9 /var/www/nextcloud/lib/private/Server.php(734): OC_App::getAppVersions()
#10 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(171): OC\Server->OC\{closure}()
#11 /var/www/nextcloud/3rdparty/pimple/pimple/src/Pimple/Container.php(122): OC\AppFramework\Utility\SimpleContainer->OC\AppFramework\Utility\{closure}()
#12 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(138): Pimple\Container->offsetGet()
#13 /var/www/nextcloud/lib/private/ServerContainer.php(171): OC\AppFramework\Utility\SimpleContainer->query()
#14 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(65): OC\ServerContainer->query()
#15 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(193): OC\AppFramework\Utility\SimpleContainer->get()
#16 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(171): OC\AppFramework\Utility\SimpleContainer->OC\AppFramework\Utility\{closure}()
#17 /var/www/nextcloud/3rdparty/pimple/pimple/src/Pimple/Container.php(118): OC\AppFramework\Utility\SimpleContainer->OC\AppFramework\Utility\{closure}()
#18 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(138): Pimple\Container->offsetGet()
#19 /var/www/nextcloud/lib/private/ServerContainer.php(171): OC\AppFramework\Utility\SimpleContainer->query()
#20 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(65): OC\ServerContainer->query()
#21 /var/www/nextcloud/lib/private/Server.php(1115): OC\AppFramework\Utility\SimpleContainer->get()
#22 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(171): OC\Server->OC\{closure}()
#23 /var/www/nextcloud/3rdparty/pimple/pimple/src/Pimple/Container.php(122): OC\AppFramework\Utility\SimpleContainer->OC\AppFramework\Utility\{closure}()
#24 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(138): Pimple\Container->offsetGet()
#25 /var/www/nextcloud/lib/private/ServerContainer.php(171): OC\AppFramework\Utility\SimpleContainer->query()
#26 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(65): OC\ServerContainer->query()
#27 /var/www/nextcloud/lib/private/Server.php(2074): OC\AppFramework\Utility\SimpleContainer->get()
#28 /var/www/nextcloud/lib/private/Files/View.php(120): OC\Server->getLockingProvider()
#29 /var/www/nextcloud/lib/private/Server.php(468): OC\Files\View->__construct()
#30 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(171): OC\Server->OC\{closure}()
#31 /var/www/nextcloud/3rdparty/pimple/pimple/src/Pimple/Container.php(122): OC\AppFramework\Utility\SimpleContainer->OC\AppFramework\Utility\{closure}()
#32 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(138): Pimple\Container->offsetGet()
#33 /var/www/nextcloud/lib/private/ServerContainer.php(171): OC\AppFramework\Utility\SimpleContainer->query()
#34 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(65): OC\ServerContainer->query()
#35 /var/www/nextcloud/lib/private/Server.php(1476): OC\AppFramework\Utility\SimpleContainer->get()
#36 /var/www/nextcloud/lib/base.php(629): OC\Server->boot()
#37 /var/www/nextcloud/lib/base.php(1171): OC::init()
#38 /var/www/nextcloud/console.php(48): require_once('...')
#39 /var/www/nextcloud/occ(11): require_once('...')
#40 {main}Error while applying update 1.53.0sh. Exiting...

Hi,

did you check your

memory_limit =

in your php.ini ?

Hi, sambilanet, thanks for replying. No, I have not checked that. How would I do that, and what should the value be? Also, how would I change it? As you might guess, Iā€™m rather a noob at much of this.

Also, not sure if this is important, but my Nextcloud is on a 32-bit system. Iā€™d never had trouble with downloads until one of the updates I did a month or so ago, though.

Hmmmā€¦ :thinking:

I canā€™t imagine that 32-bit could be a problem.

Execute this inside your nextcloud folder, like /var/www/nextcloud

  1. Check your loglevel

sudo -u www-data php occ config:list |grep loglevel

  1. Elevate your loglevel to debug

sudo -u www-data php occ log:manage --level=debug

  1. Lower your loglevel again!

sudo -u www-data php occ log:manage --level=ā€œto the level you had beforeā€

  1. Try the the upload and send the logfile here. Delete ahead private infos :warning:

  2. Maybe you can check your "limit"

php -i | grep ā€œmemory_limitā€

Thanks again for continuing to help with this.

  1. ā€œCheck your log levelā€
    Returned nothing at all - no log level shown

  2. ā€œElevate log level to debugā€
    Returned the following: https://pastebin.com/wyP6ZkkK

  3. Lower log level again:
    I donā€™t know what it was before, because the command returned nothing. Please advise what log level is appropriate.

  4. Uploading a 2.5GB file returned the following errrors:
    https://pastebin.com/23uqSQHh

*NOTE: Where ā€œNo space left on deviceā€ error appears, this is not true. The storage device for the Nextcloud OS is a 32GB SD card, and less than 7GB is used.

  1. Check memory limit
    Returned:
    memory_limit => -1 => -1

Thanks once again!

  1. sudo -u www-data php occ log:manage --level debug
  2. Is your database running ??
/etc/init.d/yourdatabase status
  1. sudo -u www-data php occ log:manage --level info | Donā€™t forget :warning:
  2. 32 better 25 GB is not that much, and if there is a warning there is a warning.. Yesterday I have lost data ā€œignoringā€ this messageā€¦ :sweat_smile:
    Check if you can upload 1 GB. Or better what size you can upload ?

Returns: Could not open input file: occ

Yes, database is running

I believe the answer here is in the PHP error logged that I linked earlier:
ā€œfile_put_contents(): content truncated from 2666934549 to 2147483647 bytesā€

So 2147483647 bytes, or whatever that comes to in MB or GB, would be the limit.

Thanks

Ok perfect,
2147483647 bytes = 2,14 GB, and if this is the solution donā€™t forget to mark it as such.
Have nice weekend.
:slight_smile:

Hi @Skyhooker,

you must edit the memory_limit, post_max_size and upload_max_filesize directives in the php.ini from the sapi which is talking to your webserver.

Here I described all the relevant values:

You did not mention the sapi your server is using but it is either /etc/php/8.0/apache2/php.ini (for libapache2-mod-php) or /etc/php/8.0/fpm/php.ini (for php-fpm) where you must edit this directives.


32-bit Linux operating systems have certain addressing and file size limitations. A 32-bit system can theoretically only address 2^32 bytes (4 GB) of memory. This means that each individual application, including the operating system itself, can only access a maximum of 4GB of RAM.

There is a similar limitation regarding file sizes. The file system used on a 32-bit Linux system can typically only handle files with a maximum size of 4GB. This is due to the 32-bit addressing, which points to a maximum number of 2^32, which is 4GB.

LFS (Large File Support) allows 32-bit kernels to support files larger than 2GB (often up to 4TB). This was made possible by using 64-bit file operations, even though the kernel itself is 32-bit.

The LFS feature has been incorporated into many modern 32-bit Unix-like operating systems to overcome file size limitations.

So your limitations are not because of the 32-bit Linux.


Much luck,
ernolf

2 Likes

Oh, sorry - I meant itā€™s the answer to your question of the maximum upload size, not the solution to the problems Iā€™m facing :slightly_smiling_face:

Thanks, ernolf. I finally figured out how to edit the php.ini file, and was successful, but I am still having errors. Hereā€™s the error when uploading a 2.5GB file:

[PHP] Error: file_put_contents(): content truncated from 2621440000 to 2147483647 bytes at /var/www/nextcloud/lib/private/Files/Storage/Local.php#313

MOVE /remote.php/dav/uploads/User/3188316710/.file
from 192.168.1.1 by User at 2024-01-07T05:07:33+00:00

It is late here, so I hope to pick this up tomorrow. Thank you.

The chunks are written to /tmp, which is normaly mounted to tmpfs, so it is limited to your ram size.

You can find out if your /tmp file is mounted to tmpfs with this query:

mount | grep '/tmp'

You can define a dedicated tmp folder for nextcloud and php, which is not limited by your ram space:

  • first create the tmp dir

    mkdir /tmp_nc
    chown www-data.www-data /tmp_nc
    
  • add to config.php

      'tempdirectory' => '/tmp_nc',
    
  • add to (or edit) php.ini

    upload_tmp_dir = "/tmp_nc"
    

What php.ini file (path) did you edit exactly?

Meanwhile you are only writing about upload (the title of this theme is about download), so the file is not yet stored on your Pi?

My first question would be, did you restart the services?

  • sudo systemctl restart apache2 php8.0-fpm
    
    (as you can see, Iā€™m assuming youā€™re using php-fpm, but I donā€™t know because youā€™re stingy with information)

Otherwise, given this error message, I might have to retract my previous statement about 32-bit limitations.
This could (very unlikely) be a 2GB limit as described here: https://en.wikipedia.org/wiki/2_GB_limit
Since Iā€™m not familiar with the architecture of the CPU and kernel used in your Pi, I canā€™t say anything definitive or rule it out. I canā€™t find anything online that indicates a 2GB limit in Raspbery Pi either. More like a 3GB limit.

The echoes from following queries could deliver more insights:

grep pae /proc/cpuinfo
cat /proc/cmdline
grep HIGHMEM /usr/src/*/.config

But after all, it could also be something completely different, something that I didnā€™t take into account. As you can see, Iā€™m not a Pi, nor an Armbian expert, perhaps someone who is more familiar with Pi problems can provide more detailed help.


Much luck,
ernolf

1 Like

Hi, ernolf, and thank you for your help and for following up. I have a pretty busy day today, but will answer your questions as I get the time. I donā€™t mean to withhold information, but Iā€™m rather new to most of this, and itā€™s a bit overwhelming.

The file I edited is /etc/php/8.0/fpm/php.ini
The memory limit is set to -1
post_max_size is set to 16G
upload_max_filesize also set to 16G

mount | grep ā€˜/tmpā€™
returns: tmpfs on /tmp type tmpfs (rw,nosuid,relatime)

I was not aware that restarting the services was required (Iā€™m a noob), but I have done so now, and also restarted the server itself. No improvement.

I included the uploads because they generated log entries that showed up when filtering for errors. I donā€™t see errors logged when downloading, but instead the files themselves are ruined. I just tried downloading two files that had been uploaded several months ago, before I began updating NextcloudPi (which is when the problems began). One was 2.5GB, the other 2.8GB. Both files stopped at the exact same filesize: 2,097,152KB, as shown in Windows file manager.

Thank you for your help!

I donā€™t think weā€™re talking about the same component of my system. The ā€œNo space left on deviceā€ errors Iā€™m getting always refer to a directory that is part of the operating system, which is on the 32GB SD card, and I have seen them most often when trying to do updates.

The file sizes mentioned in the errors are very small, on the order of megabytes, not gigabytes, so my 2GB memory should have no part in the errors. They donā€™t refer to the SATA storage HDD on my system, or to the large files Iā€™m trying to upload or download.

This means, that your /tmp directory is not located on that 32GB SD card but on tmpfs, which is in fact inside of your ram and therefore limited by the space of your ram.

The error ā€œNo space left on deviceā€ has always a reason and must be taken serious, always!


ernolf

1 Like

OK, thank you, that makes sense.

What I mean, though, is that the ā€œno space leftā€ errors themselves donā€™t mention a /tmp directory, but what seems to be a directory on the SD card itself. For instance:

ā€œ1. [PHP] Error: fread(): Write of 4096 bytes failed with errno=28 No space left on device at /var/www/nextcloud/3rdparty/icewind/streams/src/Wrapper.php#55ā€

Unless Iā€™m just misunderstanding things.

You are correct in that the error is just mentioning where in the code it was encountered without giving the exact paths to which a write was being done, it could be that those parameters (the paths) are elsewhere in the stacktrace and it could be they are just not being logged.

OK, thanks. I guess Iā€™ll try moving the tmp directory from RAM to physical storage as ernolf suggested. I have been hesitant because it wasnā€™t clear to me that this would solve the problems Iā€™m having, and I donā€™t want to create a new problem in the process.

If Iā€™m not mistaken you wrote before that you are running of an SD card in which case you will definitely be creating new problems since running /tmp/ on it will speed up itsā€™ demise.

Hmmm, thanks, Keeper. Thatā€™s why Iā€™ve been hesitant to make such changes, especially since everything worked fine before I started the series of updates a couple months ago. Iā€™d much rather find out what broke the system, and fix that. I keep hoping someone may have a solution.

Those ā€œno space left on deviceā€ errors donā€™t make any sense to me, since thereā€™s plenty of space on the physical device, and the changes that generate them are from very small files, not very large ones. I am very much a noob at this, though.