Closed Noodlesalat closed 4 months ago
Sounds like https://github.com/nextcloud/server/issues/30843 and https://github.com/nextcloud/server/issues/19682.
phpXXXXXX
Afaik, we cannot force PHP to not store files temporary on disk.
The Nextcloud data directory is located on another partition and not directly in the web directory.
Is the upload_tmp_dir on the same partition?
Thanks for your answer!
So you mean that the phpXXXXXX
file is automatically generated by php during the upload and Nextcloud has no influence on this behaviour? Would it then be possible to prevent the creation of the .part
file and only work with the phpXXXXXX
file? In other words, after a successful upload to upload_tmp_dir
, move it to the target folder in the users data directory.
The upload_tmp_dir
is indeed located on the same partition as the data directory (tmp: /mnt/tmp; data: /mnt/cloud).
I just found out that the issue also occurs with uploads via the Nextcloud client, which uses chunked uploads iirc. In this case, a phpXXXXXX
file is created in the upload_tmp_dir
and the same file is stored in the folder $DATADIR/$USERNAME/uploads/$ID?/
.
This means that an upload is always written to the hard disk twice, especially if the data dir and the upload_tmp_dir
are on the same partition.
Therefore I updated the issue titel.
So you mean that the phpXXXXXX file is automatically generated by php during the upload and Nextcloud has no influence on this behaviour?
This is my current state of knowledge.
Would it then be possible to prevent the creation of the .part file and only work with the phpXXXXXX file?
The information, which tmp file is used for the upload, is available when using https://www.php.net/manual/en/features.file-upload.post-method.php.
We are using another way to process uploads afaik https://www.php.net/manual/en/features.file-upload.put-method.php.
This issue significantly impacts my system performance. I set upload_tmp_dir to a large tmpfs disk in hopes of speeding up performance. However, what confuses me is that Nextcloud writes upload chunks from upload_tmp_dir to data_dir, then merges them in the data_dir directory before writing them to the target directory. I don't understand why Nextcloud does this, as it renders my upload_tmp_dir setting ineffective.
This means that an upload is always written to the hard disk twice, especially if the data dir and the
upload_tmp_dir
are on the same partition.
Are we sure they are not referring to the same inode and are in fact really two different files?
Maybe we can ask @juliushaertl or @icewind1991 if they know more about the handling of upload and if Nextcloud really have any potential impact on how upload_tmp_dir
is used :eyes:
checked with stat -c %i $filename
on the "same" file:
root@nextcloud /mnt/tmp # stat -c %i phpEQ8lE7
49938437
------------------------------
root@nextcloud /mnt/cloud/USERNAME/uploads/193146716 # stat -c %i 00011.ocTransferId594818750.part
44302342
It seems like the inodes differ. This also correlates with the output of iotop
as it is approximately twice my upload speed.
As far as I digged into this in the past this is expected internal php behaviour.
Any access of the php://input stream will create a tmp file if greater than 8k, otherwise the stream data will be hold in memory.
There is no way to avoid this as far as I know. PHP is also not exposing the file itself, so we can't work with that.
Closing then, unless someone is able to prove we can control this behaviour, this is a wontfix :(
⚠️ This issue respects the following points: ⚠️
Bug description
I have encountered the issue that files uploaded via WebDAV are written twice by Nextcloud. The first version is stored in php's
upload_tmp_dir
and is namedphpXXXXXX
. The second version is stored in the files target directory and is named$filename.ocTransferId$ID.part
.According to
iotop
the file is actually written twice, because the write speed to the storage is approximately twice the upload speed.Steps to reproduce
upload_tmp_dir
and file target directory for duplicate fileExpected behavior
File is either written to the target directory and gets renamed to the target filename after successful upload or file is written to php's
upload_tmp_dir
and moved to target folder after successful upload.Installation method
Community Manual installation with Archive
Nextcloud Server version
28
Operating system
Debian/Ubuntu
PHP engine version
PHP 8.2
Web server
Apache (supported)
Database engine version
MariaDB
Is this bug present after an update or on a fresh install?
Updated from a MINOR version (ex. 22.1 to 22.2)
Are you using the Nextcloud Server Encryption module?
Encryption is Disabled
What user-backends are you using?
Configuration report
List of activated Apps
Nextcloud Signing status
Nextcloud Logs
Additional info
The Nextcloud data directory is located on another partition and not directly in the web directory.