clcache
clcache copied to clipboard
CLCACHE_HARDLINK corrupts the cache
Some time ago we found that CLCACHE_HARDLINK was corrupting the cache in our CI system. We had intermittent problems until we disabled hardlinking.
A quick look at the code shows that files are copyOrLink()'d when stored and when retrieved from the cache. The file in the cache can be modified if the build folder is re-used and the compiler or other tool writes to the file.
A solution could involve deleting the object files in the build folder before invoking the compiler.
Note that I have not verified if VS truncates the files.
I'm encountering this as well. I can't be sure, but it could be when I Ctrl+C (from a cygwin terminal) to interrupt the build. I had no such trouble before enabling CLCACHE_HARDLINK.
I've been using this as a workaround:
- search the
$CLCACHE_DIR/objects
for zero-length files, and delete them all - run the build
- delete the file(s) reported as corrupt
- run the build
- Hit an error that looks like this: FileNotFoundError: [Errno 2] No such file or directory: 'D:\clcache\objects\70\70f185f939052a42810446adf246f821\object'
-
grep
the$CLCACHE_DIR/manifests
directory for that hash, and delete the found manifest. e.g.:-
find path/to/manifests -type f | xargs grep 70f185f939052a42810446adf246f821 -l | xargs rm
- (no, File Explorer's stoopid "search file contents" feature will not "search file contents" in .json.)
-
- Repeat from 2 until all fixed.
Believe it or not, this is still faster for me than blowing away the cache. (Especially if I'm rebasing or something.)
Also makes me wonder if corrupt entries could be automatically dropped / regenerated somehow.