You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Reading sharded array with multiprocessing produces wrong result #3221
i think sharding invites race conditions if multiple processes attempt to write to the same shard file at the same time. so we need a mechanism to ensure that sharded writes in a multiprocessing context are per-shard, and not per-chunk. I wonder if this is related to #3217
changed the title [-]How to work with shards and multiprocessing?[/-][+]Reading sharded array with multiprocessing produces wrong result[/+]on Jul 10, 2025
it would be great to get some help fixing this. I don't have time to look into it this week but I think this is an important bug. I'm adding the "help wanted" tag and also pinging @zarr-developers/python-core-devs
Activity
d-v-b commentedon Jul 10, 2025
i think sharding invites race conditions if multiple processes attempt to write to the same shard file at the same time. so we need a mechanism to ensure that sharded writes in a multiprocessing context are per-shard, and not per-chunk. I wonder if this is related to #3217
ziw-liu commentedon Jul 10, 2025
The test linked in OP is only reading in parallel but still fails.
ziw-liu commentedon Jul 10, 2025
Here's a script version of the test in case reproducing the dev environment is too much trouble:
On Linux it doesn't work when
shards=(20,), but passes withshards=(10,)(i.e. equal to chunks).d-v-b commentedon Jul 10, 2025
thanks for the reproducer. hopefully this is a simple bug to fix, since it's on the reading side
ziw-liu commentedon Jul 10, 2025
It seems like it's only reading the last chunk.
results[0]with chunk size fixed to 10:And all the workers read the same results independent of the number of workers.
[-]How to work with shards and multiprocessing?[/-][+]Reading sharded array with multiprocessing produces wrong result[/+]ziw-liu commentedon Jul 14, 2025
@dstansby can you add the 'bug' label back?
dstansby commentedon Jul 14, 2025
sorry - not sure why I removed it!
d-v-b commentedon Aug 11, 2025
it would be great to get some help fixing this. I don't have time to look into it this week but I think this is an important bug. I'm adding the "help wanted" tag and also pinging @zarr-developers/python-core-devs
ziw-liu commentedon Sep 19, 2025
Appears to be fixed in 3.1.3 by #3299.