当前位置:网站首页>TiDB 6.0:让 TSO 更高效丨TiDB Book Rush
TiDB 6.0:让 TSO 更高效丨TiDB Book Rush
2022-06-27 11:46:00 【InfoQ】
1. 前言
- TSO 分配由 PD Leader 节点提供,大量请求下会导致 Leader 节点 CPU 利用率增高,影响事务延迟。
- PD Follower 节点基本处于空闲状态,系统资源利用率较低。
- TiDB 跨数据中心访问 PD Leader 时,数据中心间的延迟导致事务延迟增加。
2. TSO

3. Follower Proxy

4. RC Read TSO 优化
- Select 语句执行时不从 PD 获取 TSO 作为 for_update_ts,而是使用上一个有效的 TSO 作为 for_update_ts(即为 read_ts)。如果是事务中的第一个语句则是 start_ts,否则是上一个 SQL 的 for_update_ts。
- 构建执行计划并执行,发送到 tikv 的数据读取请求(pointget、coprocessor)会带上 RcReadCheckTS 标志。
- 数据读取请求使用前面获得的 read_ts 做一致性读取,并将数据返回 tidb server。
- TiKV 会检查返回的数据是否有更新版本,如果有更新的版本则返回 WriteConflict 错误,否则返回数据后正常结束执行。
- 如果此时 tidb 还未向 client 发送数据则会从 PD 获取最新的 TSO 作为 for_update_ts 重新执行整个查询,否则会向 client 返回错误。
5. Local TSO
- Local TSO
- Global TSO
- Global tso allocator 收集所有 local tso allocator 的最大 local tso。
- 从所有 local tso 中选出一个最大的 local tso 作为 max_tso 下发到 local allocator。
- 如果 max_tso 比自己的大则更新 TSO 为 max_tso,否则直接返回成功。
- PD、TiKV、TiDB server 均需要根据实际部署设置 label,为保证高可用每个 DC 的 PD 数量应>1。


- 开启库或表级 Placement Rules in SQL,根据地域和业务关系进行调度。
CREATE PLACEMENT POLICY dc1_leader LEADER_CONSTRAINTS="DC1" FOLLOWER_CONSTRAINTS="DC1,DC2,DC3" FOLLOWERS=2; Alter table new_order PARTITION p0 PLACEMENT POLICY dc1_leaders;- 设置 PD 参数 enable-local-tso=on 使用 tiup reload 重启 PD 开启 Local TSO 功能。启用之后可通过 pd-ctl -u pd_ip:pd_port member 中 tso_allocator_leaders 项内容查看每个中心的 local tso allocator leader。
6. 测试
6.1 测试环境

6.2 TSO Follower Proxy


6.3 RC Read TSO


6.4 Local TSO

7. 总结
边栏推荐
- i.mx6ull(单片机) c语言环境搭建
- pull request
- [tcapulusdb knowledge base] Introduction to tcapulusdb system management
- dried food! What problems will the intelligent management of retail industry encounter? It is enough to understand this article
- [tcapulusdb knowledge base] tcapulusdb doc acceptance - table creation approval introduction
- $15.8 billion! 2021 the world's top15 most profitable hedge fund giant
- Drive to APasS!使用明道云管理F1赛事
- Mathematical knowledge -- ideas and examples of game theory (bash game, Nim game, wizov game)
- 2022CISCN华中 Web
- 动态规划【三】(区间dp)石子合并
猜你喜欢

JSP自定义标签

How to modify a node_ Files in modules

2022ciscn central China Web

AutoCAD - three pruning methods

$15.8 billion! 2021 the world's top15 most profitable hedge fund giant

StarCraft's Bug King ia retired for 2 years to engage in AI, and lamented that it was inferior

MapReduce practical cases (customized sorting, secondary sorting, grouping, zoning)

Unity Shader学习(一)认识unity shader基本结构

AUTOCAD——三种修剪方式

怎么找相同台词的影视片段?这8个电影搜索神器,一句台词找到对应片段
随机推荐
Drive to APasS! Use Mingdao cloud to manage F1 events
最短编辑距离(线性dp写法)
R语言使用epiDisplay包的poisgof函数对泊松回归(Poisson Regression)执行拟合优度检验、检验是否存在过度离散问题(overdispersion)
. Net6 access skywalking link tracking complete process
[tcapulusdb knowledge base] Introduction to tcapulusdb system management
Jerry's adding timer interrupt [chapter]
Wait, how do I use setmemorylimit?
MapReduce practical cases (customized sorting, secondary sorting, grouping, zoning)
C # WPF realizes undo redo function
干货!零售业智能化管理会遇到哪些问题?看懂这篇文章就够了
This privatized deployed enterprise knowledge base makes telecommuting a zero distance
FileOutputStream
[tcapulusdb knowledge base] tcapulusdb operation and maintenance doc introduction
MapReduce实战小案例(自定义排序、二次排序、分组、分区)
Popular science of device review: popular science of innovative medical device series - sternum plate products
Qstype implementation of self drawing interface project practice (I)
Wechat applet payment password input
Thinkphp6 interface limits user access frequency
Unity shader learning (I) understanding the basic structure of unity shader
Usage of rxjs mergemap
