Permission denied when multiple Processes write to the same file
Zarr version
3.1.3
Numcodecs version
0.16.3
Python Version
3.13.4
Operating System
Windows 11 24H2
Installation
using pip into virtual environment
Description
I am encountering an issue when writing to a Zarr array using Python multiprocessing. (Or more specifically: Missuse Dask's Multiprocessing, as i write into a zarr array inside a map_block function) The problem occurs when the array chunks contain multiple elements. Writing works correctly when each chunk contains only a single element, but fails when the chunk size is larger.
Example:
Here group is a zarr group and zarr_array is another zarr array.
My code that writes to b_arr in a multprocessed manner works, when this creates the array: b_arr=group.create_array( name=name, shape=zarr_array.cdata_shape, chunks=(1, 1), dtype=np.uint64, fill_value=0, )
and here not: b_arr=group.create_array( name=name, shape=zarr_array.cdata_shape, chunks=zarr_array.cdata_shape, dtype=np.uint64, fill_value=0, )
I believe that zarr should work when mutliple processes concurrenty write into an array, so i consider it a bug.
Steps to reproduce
# /// script
# requires-python = ">=3.11"
# dependencies = [
# "zarr@git+https://github.com/zarr-developers/zarr-python.git@main",
# ]
# ///
#
# This script automatically imports the development branch of zarr to check for issues
import zarr
# your reproducer code
# zarr.print_debug_info()
Additional output
No response
I am getting this error as well
File [~\AppData\Roaming\uv\python\cpython-3.12.9-windows-x86_64-none\Lib\pathlib.py:1376](http://localhost:8888/lab/workspaces/auto-P/tree/dev/~/AppData/Roaming/uv/python/cpython-3.12.9-windows-x86_64-none/Lib/pathlib.py#line=1375), in Path.replace(self, target)
1366 def replace(self, target):
1367 """
1368 Rename this path to the target path, overwriting if that path exists.
1369
(...) 1374 Returns the new Path instance pointing to the target path.
1375 """
-> 1376 os.replace(self, target)
1377 return self.with_segments(target)
PermissionError: [WinError 5] Access is denied: 'zarr\\plane01_stitched.zarr\\c\\9\\0\\0.f03a0e3c2a8747b5a96eb94e4a5c04b3.partial' -> 'zarr\\plane01_stitched.zarr\\c\\9\\0\\0'
I can confirm as well
Same here