tikv / tikv/client-rust

Non-exclusive get_for_update

Open
#483 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
425
Forks
163
Avg merge
10h 51m
Merged PRs (30d)
3

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!

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the Rust transaction API and the get_for_update implementation referenced in the issue, then compare its behavior with RocksDB's exclusive and non-exclusive modes. Determine whether TiKV supports shared and exclusive locks for this index-rebuild scenario; done would be a documented supported approach or a clearly scoped feature proposal.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
databases, distributed-systems
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.