summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAngelos Evripiotis <jevripiotis@bloomberg.net>2019-03-13 10:52:57 +0000
committerAngelos Evripiotis <jevripiotis@bloomberg.net>2019-03-13 13:41:23 +0000
commite8e04d8a1471cfbef045b8721624c1f2d5964668 (patch)
tree5603a7cbde6e3d4b646ca08a247569e2b072e1b3
parent2c3dfa4e1b92ead066b3fa25fe7c3037b4ba6c58 (diff)
downloadbuildstream-aevri/tmpdir_for_cache_size.tar.gz
cascache: atomically save size via tmpdir insteadaevri/tmpdir_for_cache_size
Instead of doing the atomic 'mv into place' using a temporary file in the 'cas' directory, use the sibling 'tmp' directory instead. This will avoid the situation where CacheSizeJob encounters a temporary file in the cas directory. This can happen because CacheSizeJob does not always run with an exclusive lock on the cas directory, and BuildQueue updates the cache size whenever a BuildJob completes.
-rw-r--r--buildstream/_cas/cascache.py2
1 files changed, 1 insertions, 1 deletions
diff --git a/buildstream/_cas/cascache.py b/buildstream/_cas/cascache.py
index 802fc13fd..1b89d38ed 100644
--- a/buildstream/_cas/cascache.py
+++ b/buildstream/_cas/cascache.py
@@ -1179,7 +1179,7 @@ class CASQuota:
def _write_cache_size(self, size):
assert isinstance(size, int)
size_file_path = os.path.join(self.casdir, CACHE_SIZE_FILE)
- with utils.save_file_atomic(size_file_path, "w") as f:
+ with utils.save_file_atomic(size_file_path, "w", tempdir=self.cas.tmpdir) as f:
f.write(str(size))
# _get_cache_volume_size()