Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WriteBatch is not thread safe #154

Open
BusyJay opened this issue Nov 7, 2017 · 4 comments
Open

WriteBatch is not thread safe #154

BusyJay opened this issue Nov 7, 2017 · 4 comments

Comments

@BusyJay
Copy link
Member

BusyJay commented Nov 7, 2017

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

@siddontang
Copy link

I think the user will rarely use a WriteBatch cross multi-threads, maybe make it with no send, no sync?

@BusyJay
Copy link
Member Author

BusyJay commented Nov 7, 2017

It may be a workaround, but certainly not a good design and feels weird.

@alanhoff
Copy link

I think it's pretty common to have multiple writes distributed across threads, that should include WriteBatch, no?

@BusyJay
Copy link
Member Author

BusyJay commented Nov 22, 2017

... 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants