rust-rocksdb
rust-rocksdb copied to clipboard
`WriteBatch` is not thread safe
From what I can see, WriteBatch is not thread safe. We should change the put method to take a mut ref instead.
https://github.com/facebook/rocksdb/blob/e03377c7fd86f117c6c64d35955140dab400eb3c/db/write_batch.cc#L525-L547
I think the user will rarely use a WriteBatch cross multi-threads, maybe make it with no send, no sync?
It may be a workaround, but certainly not a good design and feels weird.
I think it's pretty common to have multiple writes distributed across threads, that should include WriteBatch, no?
... it's pretty common to have multiple writes distributed across threads ...
That's exact the reason why DB::write is synchronized.
... that should include WriteBatch ...
No. Generally, WriteBatch is created and flushed in the same thread.