Open henryborchers opened 4 days ago
We very intentionally do not lock the cache, it's designed to be concurrency safe. My guess is that error is something to do with the file being created by a different user...?
Are both containers running as the same user?
They should be running as the same user. They are based on the same image.
To give you a little more context, these Docker containers are spun up by Jenkins as part of the pipeline. When building a wheel with an extension, I build the wheel for each supported version of Python in their own Docker container (based on the same image that has all the supported versions of Python installed) running in parallel. When these containers run, they run with the exact same settings, same environment variables, same user, and same path to cache mounted on the host system.
When the containers run one at a time, everything runs fine. It uses the cache without an issue. However, when multiple containers are accessing the same cache directory, I get the permission errors.
Is the error always when trying to write the CACHEDIR.TAG
or do you see this for other files too?
Other files as well. If you want I can put the stack trace for those here too
Actually, I think it might be only CACHEDIR.TAG that I'm running into. At least when using Linux.
Let's see if https://github.com/astral-sh/uv/pull/7550 resolves this then
While building wheels on my CI machine, I've been running into an issue involving the cache directory trying to access and write to the same files. This only happens when I have two or more containers running with the same mounted path, the location of UV_CACHE_DIR aka cache path. This doesn't happen every time, just when uv is trying to access the same files in the cache. For this reason the ci pipeline could be fine depending on which stages are running at the same time.
It looks like it's possibly a race condition that wasn't a problem when I was using pip. Is there a "process locking file" located outside of the UV_CACHE_DIR that I should also be mounting so that the cache isn't written to at the same time?
uv==2.12 build==1.2.1
Note: In this example, I'm using Python 3.8 on Linux but it's a happens with all version in Linux and Windows Docker containers.
Docker Command used:
docker run -ti -v uvcache:/.cache/uv -e UV_CACHE_DIR=/.cache/uv some_docker_image_that_has_uv_installed
Uv command used inside the container:
python3.8 -m build --wheel --installer=uv
Output