1.6 Read and Write data in the TiDB database platform(TiDB 中的读写流程)

学习时长:

5min

课程收获:

对 TiDB 整体架构以及读写路程有大概的了解

课程内容:

本课程主要包括 TiDB 架构的简单介绍、各个组件的作用,以及读写请求在 TiDB 中的过程

TiDB 整体架构

  • TiDB
  • TiKV
  • PD

TiDB 对读请求的处理

  1. the client establish connection to TiDB and send a request to TiDB
  2. TIDB gets SQL from the request
  3. TiDB parses and compiles the SQL, make and optimize the query plan
  4. TiDB gets start_ts from PD
  5. TiDB gets the metadata of table and transfers the query plan to a series of executor
  6. TiDB sends the coprocessor request to TiKV through gRPC
  7. TiKV receives the request, searches for the data, and sends thse result to TiDB
  8. TiDB receives all the data from TiKVand handles the result
  9. TiDB sends the result to the client

TiDB 对写请求的处理

  1. The client establish connection to TiDB and send a request to TiDB
  2. TiDB gets SQL from the request
  3. TiDB parses and compiles the SQL, make and optimize the query plan
  4. TiDB gets start_ts from PD
  5. TiDB gets the metadata of table and transfers the query plan to a series of executor
  6. TiDB make a commit request
  7. TiKV commit the data using two-ghase commit (prewrite/commit) according to the percolator, TiDB will gets_commit_ts at commit phase (2PC)
  8. TiKV send the result to TiDB
  9. TiDB send the result to client

学习过程中参考的其他资料