Reading Data from RocksDB

This topic has been translated from a Chinese forum by GPT and might contain errors.

Original topic: rocksdb读取数据

| username: chenhanneu

[TiDB Usage Environment] Production Environment / Testing / PoC
[TiDB Version]
[Reproduction Path] What operations were performed when the issue occurred
[Encountered Issue: Issue Phenomenon and Impact]
Each TiKV instance has two RocksDB instances, one for storing Raft logs (commonly referred to as raftdb) and the other for storing user data and MVCC information (commonly referred to as kvdb).
When the client submission is successful, does it count as successful once the Raft log is written, or must it be written to kvdb?
[Resource Configuration] Go to TiDB Dashboard - Cluster Info - Hosts and take a screenshot of this page
[Attachments: Screenshots/Logs/Monitoring]

| username: zhanggame1 | Original post link

Distributed databases are quite complex. You can check out the SQL execution section in the 101 course.
TiDB Database Core Principles and Architecture (101) (

| username: tidb菜鸟一只 | Original post link

My understanding:
For a simple statement
insert into t values(1);
The process at the Raft layer can be roughly divided into 5 steps:

  1. Propose: The Leader converts the insert operation into a Raft Log, which includes the Region ID, Raft Log ID, and the specific log content.
  2. Append: The Leader persists the Raft Log to the local RocksDB (raftdb).
  3. Replicate (Followers Append): The Leader replicates the Raft Log to the Followers for synchronization. After receiving the Raft Log, the Followers persist it to the local RocksDB (raftdb) and notify the Leader of the successful synchronization.
  4. Committed: When the Leader receives successful Append messages from the majority of nodes (including the Leader itself), it considers the Raft Log to be successfully committed.
  5. Apply: The Raft log is retrieved from raftdb and applied to kvdb.
    Step 5 may not necessarily be executed at this point, as the user has not yet executed the commit for the transaction. If the user executes commit, step 5 will be executed. If the user executes rollback, step 5 will not be executed.
| username: redgame | Original post link

Need to write to kvdb

| username: Fly-bird | Original post link

Writing to kvdb is the real writing.