diff options
author | Greg Becker <becker33@llnl.gov> | 2021-05-12 23:56:20 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-05-13 06:56:20 +0000 |
commit | f8740c8c759ac8e8d4b7749628273254ea83894e (patch) | |
tree | 6cacff2d19079c5da718c37842673223d99daaac /var | |
parent | ee73f75239009185cedc53c09cc0e59528a2ba07 (diff) | |
download | spack-f8740c8c759ac8e8d4b7749628273254ea83894e.tar.gz spack-f8740c8c759ac8e8d4b7749628273254ea83894e.tar.bz2 spack-f8740c8c759ac8e8d4b7749628273254ea83894e.tar.xz spack-f8740c8c759ac8e8d4b7749628273254ea83894e.zip |
env views: make view updates atomic (#23476)
Currently, environment views blink out of existence during the view regeneration, and are slowly built back up to their new and improved state. This is not good if other processes attempt to access the view -- they can see it in an inconsistent state.
This PR fixes makes environment view updates atomic. This requires a level of indirection (via symlink, similar to nix or guix) from the view root to the underlying implementation on the filesystem.
Now, an environment view at `/path/to/foo` is a symlink to `/path/to/._foo/<hash>`, where `<hash>` is a hash of the contents of the view. We construct the view in its content-keyed hash directory, create a new symlink to this directory, and atomically replace the symlink with one to the new view.
This PR has a couple of other benefits:
* It future-proofs environment views so that we can implement rollback.
* It ensures that we don't leave users in an inconsistent state if building a new view fails for some reason.
For background:
* there is no atomic operation in posix that allows for a non-empty directory to be replaced.
* There is an atomic `renameat2` in the linux kernel starting in version 3.15, but many filesystems don't support the system call, including NFS3 and NFS4, which makes it a poor implementation choice for an HPC tool, so we use the symlink approach that others tools like nix and guix have used successfully.
Diffstat (limited to 'var')
0 files changed, 0 insertions, 0 deletions