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

opam behavior when disk is full #2715

Open
Drup opened this issue Oct 11, 2016 · 9 comments
Open

opam behavior when disk is full #2715

Drup opened this issue Oct 11, 2016 · 9 comments

Comments

@Drup
Copy link
Contributor

Drup commented Oct 11, 2016

On 2.0, when doing opam switch remove foo while disk is full:

  • opam fails with an exception
  • the switch is not removed
  • ~/.opam/config is replaced by an empty file

I understand that handling a full disk is complicated, but I would like if it at least didn't made my opam install unusable. :(

@AltGr
Copy link
Member

AltGr commented Oct 14, 2016

Sorry about it!
Are there standard solutions for handling this ? The one I can imagine is to always write to temp files, then swap. We would have to update how we lock the files (to prevent concurrent read/writes) since at the moment it's done on the file's inode.

@AltGr
Copy link
Member

AltGr commented Nov 7, 2016

On second thought, just removing the file in the handler of exceptions that are raised during write should already help a lot, shouldn't it ?

AltGr added a commit to OCamlPro/opam that referenced this issue Nov 14, 2016
Should help mitigate ocaml#2715, although it's not a real solution
(no file is better than an incomplete file, but keeping the older
version of the file when it exists would probably be a better behaviour,
if not, obviously, perfect)
@dra27
Copy link
Member

dra27 commented May 21, 2017

Might having a small permanent file created by opam init help in some cases - i.e. a small reservation of disk space? Obviously doesn't help if you have another active process which is chomping any disk space remaining, but it might be enough to ensure that config files are written back?

@cfcs
Copy link

cfcs commented Aug 16, 2019

I just ran into this problem. I think doing atomic writes of files (writing, fsyncing, then swapping the files) would make sense and avoid a lot of problems with low disk space.

@rjbou
Copy link
Collaborator

rjbou commented Apr 27, 2020

Problem encountered with an upgrade & repo config file in #4157

@rjbou
Copy link
Collaborator

rjbou commented Mar 10, 2023

@dra27 said

Note that there's a commit already for atomic writes in bb0d675 (in #5417) - that could possibly be extracted early?

@sim642
Copy link

sim642 commented Feb 12, 2024

On opam 2.1.2 I somehow managed to hit an even weirder instance of this issue. After running out of disk space during switch creation, ~/.opam/config was not just replaced by an empty file, but this abomination: opam-config-vpl-k.txt.
It appears to have some kind of terminal output with escapes prepended to the usual config file??? I don't really understand how that can even happen. Some file descriptor mixup?

@kit-ty-kate
Copy link
Member

@pitag-ha also hit the same issue last week with also some sort of corruption of the file description. We have no idea what's happening there.

@kit-ty-kate
Copy link
Member

kit-ty-kate commented Aug 13, 2024

The file corruption issue should be fixed by #5489 in opam 2.3, however the more general issue of having partial states kept around is more complicated to fix so i'm keeping this issue open for it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants