From e8e04d8a1471cfbef045b8721624c1f2d5964668 Mon Sep 17 00:00:00 2001 From: Angelos Evripiotis Date: Wed, 13 Mar 2019 10:52:57 +0000 Subject: cascache: atomically save size via tmpdir instead 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. --- buildstream/_cas/cascache.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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() -- cgit v1.2.1