opam icon indicating copy to clipboard operation
opam copied to clipboard

opam behavior when disk is full

Open Drup opened this issue 9 years ago • 9 comments
trafficstars

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. :(

Drup avatar Oct 11 '16 14:10 Drup

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 avatar Oct 14 '16 09:10 AltGr

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 avatar Nov 07 '16 17:11 AltGr

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?

dra27 avatar May 21 '17 15:05 dra27

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.

cfcs avatar Aug 16 '19 03:08 cfcs

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

rjbou avatar Apr 27 '20 11:04 rjbou

@dra27 said

Note that there's a commit already for atomic writes in https://github.com/ocaml/opam/commit/bb0d675dba3c6c128470d7fc41160837bf757a78 (in https://github.com/ocaml/opam/pull/5417) - that could possibly be extracted early?

rjbou avatar Mar 10 '23 09:03 rjbou

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?

sim642 avatar Feb 12 '24 12:02 sim642

@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 avatar Mar 04 '24 20:03 kit-ty-kate

The file corruption issue should be fixed by https://github.com/ocaml/opam/pull/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.

kit-ty-kate avatar Aug 13 '24 17:08 kit-ty-kate