# TiKV Data Writes Process

![`smart`](./student-guide/diagram/TiKVDataWrites_aa_001_20221014.png)

----------------------------------------------------------------------

TiKV data writing process

First, the scheduler pool module is responsible for coordinating transaction concurrent write collisions, and writes down the received modify operations. When there is a key value write conflict (such as: lock conflict, version conflict, etc.), the scheduler uses latch to coordinate, and the thread that gets the latch sends the write request to raftstore module, threads that do not get latch will wait.

Second, after the raftstore thread module receives a write request, converts the write request into a Raft log and writes it to rockdb raft, which is responsible for persisting these raft logs. At the same time, the raftstore module will replica raft logs to rockdb raft on other TiKV (including copies written to the region), ready to be written to other region replica.

Finally, since the Raft logs are stored in rockdb raft, the apply module will apply these raft logs to rocksdb kv. At this time, write operations are persisted to rockdb kv.
