0

I have a job that currently writes to a writeBatch sequentially. I want to split it into a few threads, since writing to a writeBatch is not thread-safe; I thought that each thread would have its writeBatch, and at the end, all batches will be merged into one to keep the write atomic.

I didn't find an API for it. Does one exist? Any alternative approach I can take?

1 Answer 1

0

Unfortunately, I don't think such merge/append WriteBatches API exists by looking into https://github.com/facebook/rocksdb/blob/main/include/rocksdb/write_batch.h, which you might already have looked into.

Is there any reason why you'd like to split it into few threads instead of writing to a write batch sequentially? With the above finding of no such an API, it seems that splitting into threads won't give any benefit at least in speeding things up.

If multi-thread with write batch can't be avoided, you may consider implementing your own external synchronization on write batch.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.