如果是并发读/写访问,会发生什么?

2024-06-02 04:32:18 发布

您现在位置:Python中文网/ 问答频道 /正文

zarr tutorial中写着:

Zarr arrays have not been designed for situations where multiple readers and writers are concurrently operating on the same array.

如果真的发生了会怎样?它会崩溃吗?未定义的行为?它是缓慢还是低效?你知道吗

编辑: 支持多个写入程序和多个读取器:

By data source we mean that multiple concurrent read operations may occur. By data sink we mean that multiple concurrent write operations may occur, with each writer updating a different region of the array

示例:

synchronizer = zarr.ProcessSynchronizer('data/example.sync') z = zarr.open_array(..., synchronizer=synchronizer)


Tags: thedatabythatmultiplemeanarrayconcurrent
1条回答
网友
1楼 · 发布于 2024-06-02 04:32:18

按照他们自己的文档,默认行为是不同步。你知道吗

因此,它不会很慢/效率低下—如果您确实有同步,并且工作人员必须等待其他工作人员释放资源后才能继续,则会发生这种情况。你知道吗

它也不会崩溃,至少在没有第三方干扰的情况下不会崩溃-没有任何东西限制访问,我推断没有针对这种情况的运行时检查,这种情况可能会引发设计错误。你知道吗

未定义?不完全是,但我们越来越近了。假设默认情况下确实没有检查或锁定,那么您将得到一个竞争条件,即如果您的写入程序首先访问您的数据,那么第二个尝试读取数据的读取器只会看到写入程序所写的内容。你知道吗

相反,如果你的读卡器首先得到它肮脏的小IO,它将在被写卡器覆盖之前读取原始数据。如果您有两个编写器,则以较晚者为准,将确定数据的最终形状。你知道吗

对于>;2个读者/作者来说也是如此;我把弄清楚由此产生的混乱的具体情况作为一项练习留给你。你知道吗

相关问题 更多 >