-
Notifications
You must be signed in to change notification settings - Fork 136
Description
Hey!
I'm looking for an alternative to rocksdb's get_for_update method. My goal is to basically implement an RwLock between transactions.
In rocksdb, AFAIU I can use get_for_update
with exclusive = false
for my read locks, and with exclusive = true
for my write locks.
However, I can't find any way to do something similar with tikv. Do you know if one such way actually exists, or is it unsupported?
For more context, I have an index that I want to rebuild. And I don't want to implement a full shadow-index like TiDB seems to do, among other reasons because I can't find a way to ask TiKV to stream all modified keys to me. So in order to avoid anyone writing while I'm rebuilding the index, I want to just have all transactions touching the index (be it read-only or write-only) to take a shared lock on the index table; and to have the index-rebuilding transaction take an exclusive lock on the index table.
Does that make sense to you, and if yes how would you implement that with TiKV?
Anyway, TiKV seems very interesting from afar! I hope I'll soon have a chance to start using it in practice too 😄
PS: I also checked the source code, and it seems to be following basically the same path for get_for_update as for put, so I'm expecting that two concurrent get_for_update will write-conflict. But maybe I'm misunderstanding the code and get_for_update is actually never exclusive, in which case I could just have my read transactions use get_for_update, and my write transactions use put with some random value!