Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Config file truncated when low on disk space #25175

Closed
simon816 opened this issue Jan 17, 2021 · 13 comments · Fixed by #36691
Closed

Config file truncated when low on disk space #25175

simon816 opened this issue Jan 17, 2021 · 13 comments · Fixed by #36691
Assignees
Labels
2. developing Work in progress 26-feedback bug good first issue Small tasks with clear documentation about how and in which place you need to fix things in. high
Milestone

Comments

@simon816
Copy link

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.

The bug

When the disk that Nextcloud is installed on is full (an admittedly unpredictable scenario), the config file is truncated. This happened during an update in my case.

Steps to reproduce

  1. cat config/config.php, observe config values
  2. Fill up disk space, e.g. dd if=/dev/zero of=file.dat bs=1024 count=10000000
  3. Perform action that changes config file, e.g. occ maintenance:mode --on
  4. cat config/config.php observe an empty file

Expected behaviour

Config file is not truncated when no disk space.

Actual behaviour

Config is left empty, Nextcloud believes it is no longer installed and wants a CAN_INSTALL file.

Server configuration

Operating system:
Ubuntu 18.04.5 LTS

Web server:
apache2 2.4.29-1ubuntu4.14

Database:
mariadb 10.1.44

PHP version:
PHP 7.2.24-0ubuntu0.18.04.6

Nextcloud version: (see Nextcloud admin page)
20.0.5

@simon816 simon816 added 0. Needs triage Pending check for reproducibility or if it fits our roadmap bug labels Jan 17, 2021
@szaimen
Copy link
Contributor

szaimen commented Jun 22, 2021

Is this Issue still valid in NC21.0.2? If not, please close this issue. Thanks! :)

@ghost
Copy link

ghost commented Jul 22, 2021

This issue has been automatically marked as stale because it has not had recent activity and seems to be missing some essential information. It will be closed if no further activity occurs. Thank you for your contributions.

@ghost ghost added the stale Ticket or PR with no recent activity label Jul 22, 2021
@simon816
Copy link
Author

Can confirm on NC 21.0.2.1

Created an Ubuntu 20.04 VM with Nextcloud installed and filled the disk:
image

@ghost ghost removed the stale Ticket or PR with no recent activity label Jul 23, 2021
@szaimen szaimen added 1. to develop Accepted and waiting to be taken care of high and removed 0. Needs triage Pending check for reproducibility or if it fits our roadmap needs info labels Jul 27, 2021
@szaimen
Copy link
Contributor

szaimen commented Jul 27, 2021

cc @nextcloud/server seems like this is still happening

@juliusknorr
Copy link
Member

I think we should probably write the new content to a temp file next to the existing one and the do a rename as any other checks for available space might still lead to scenarios where the check passes but the write then fails if the disk runs out of space in the meantime.

@juliusknorr juliusknorr added the good first issue Small tasks with clear documentation about how and in which place you need to fix things in. label Aug 2, 2021
@stefan123t
Copy link

stefan123t commented Nov 7, 2021

What about the file permissions associated with the original config.php ?
Are facls carried over too ?
Would it be better to first append the necessary bytes (eg comment or newlines) to the file and later write the new contents once the file is large enough ?

@come-nc
Copy link
Contributor

come-nc commented Sep 15, 2022

Fixed by #34009

@come-nc come-nc closed this as completed Sep 15, 2022
@come-nc come-nc added 4. to release Ready to be released and/or waiting for tests to finish and removed 1. to develop Accepted and waiting to be taken care of labels Sep 15, 2022
@come-nc come-nc added this to the Nextcloud 25 milestone Sep 15, 2022
@come-nc come-nc self-assigned this Sep 15, 2022
@come-nc
Copy link
Contributor

come-nc commented Nov 15, 2022

Fixed by #34009

Reverted #34137

@come-nc come-nc reopened this Nov 15, 2022
@szaimen szaimen removed the 4. to release Ready to be released and/or waiting for tests to finish label Jan 23, 2023
@szaimen szaimen added 0. Needs triage Pending check for reproducibility or if it fits our roadmap 26-feedback labels Jan 23, 2023
@szaimen szaimen added 2. developing Work in progress and removed 0. Needs triage Pending check for reproducibility or if it fits our roadmap labels Feb 13, 2023
@szaimen
Copy link
Contributor

szaimen commented Feb 13, 2023

Hi @simon816 can you please check if #36691 fixes the issue for you? Thanks a lot! :)

@simon816
Copy link
Author

Hi @szaimen, indeed it does, thanks. Of course there's a TOCTOU race condition there but I expect it's fine for the majority of cases.

@nursoda
Copy link

nursoda commented Feb 15, 2023

I see these messages in log for each web directory access in NC26beta3:

disk_free_space(): No such file or directory at …/lib/private/Files/Storage/Local.php#421
full nextcloud.log entry
{
  "reqId": "xucm63dW56R2nOpKqqUD",
  "level": 3,
  "time": "2023-02-15T14:59:17+01:00",
  "remoteAddr": "192.168.1.2",
  "user": "MYUSER",
  "app": "PHP",
  "method": "PROPFIND",
  "url": "/remote.php/dav/files/SOMEPATH",
  "message": "disk_free_space(): No such file or directory at /DATAFOLDER/lib/private/Files/Storage/Local.php#421",
  "userAgent": "Mozilla/5.0 (X11; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/110.0",
  "version": "26.0.0.5",
  "data": {
    "app": "PHP"
  }
}

Is that related with this enhancement? This is not a race condition, this happens on each access and should be fixed.

@szaimen
Copy link
Contributor

szaimen commented Feb 15, 2023

Is that related with this enhancement?

It is not included in nc26beta3 yet so unrelated.

@nursoda
Copy link

nursoda commented Feb 15, 2023

Found the issue – it's an older one, not 26 specific.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2. developing Work in progress 26-feedback bug good first issue Small tasks with clear documentation about how and in which place you need to fix things in. high
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants