当前位置:网站首页>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. 总结
边栏推荐
- R语言使用epiDisplay包的dotplot函数通过点图的形式可视化不同区间数据点的频率、使用by参数指定分组参数可视化不同分组的点图分布、使用dot.col参数指定分组数据点的颜色
- alibaba jarslink
- c/s 架构
- 想学好C语言,操作符也很重要
- Time management understood after being urged to work at home
- After Jerry's sleep, the regular wake-up system continues to run without resetting [chapter]
- 解开C语言的秘密《关键字》(第六期)
- pull request
- Mathematical knowledge -- ideas and examples of game theory (bash game, Nim game, wizov game)
- Online bidding of Oracle project management system
猜你喜欢

面试突击60:什么情况会导致 MySQL 索引失效?
![[tcapulusdb knowledge base] Introduction to tcapulusdb general documents](/img/04/b1194ca3340b23a4fb2091d1b2a44d.png)
[tcapulusdb knowledge base] Introduction to tcapulusdb general documents

Jwas: a Bayesian based GWAS and GS software developed by Julia

On ticheck
![[tcapulusdb knowledge base] tcapulusdb operation and maintenance doc introduction](/img/04/b1194ca3340b23a4fb2091d1b2a44d.png)
[tcapulusdb knowledge base] tcapulusdb operation and maintenance doc introduction

Nvme2.0 protocol - new features

alibaba jarslink
![[tcapulusdb knowledge base] tcapulusdb doc acceptance - transaction execution introduction](/img/d9/f6735906a130834c4b3e28de2b2617.png)
[tcapulusdb knowledge base] tcapulusdb doc acceptance - transaction execution introduction

想学好C语言,操作符也很重要

数学知识——博弈论(巴什博奕、尼姆博奕、威佐夫博奕)思路及例题
随机推荐
pull request
Research Report on the overall scale, major manufacturers, major regions, products and application segments of hydraulic torque in the global market in 2022
聊聊 Go 语言与云原生技术
Redis distributed lock 15 ask, what have you mastered?
This privatized deployed enterprise knowledge base makes telecommuting a zero distance
Summary of qstype class usage (III)
优博讯出席OpenHarmony技术日,全新打造下一代安全支付终端
MapReduce实战小案例(自定义排序、二次排序、分组、分区)
i. Construction of mx6ull C language environment
Wechat applet realizes five-star evaluation
How to adjust an integer that is entered in Excel but always displays decimals?
Four memory areas (stack, heap, global, code area)
[tcapulusdb knowledge base] tcapulusdb system user group introduction
最大路径和问题(摘樱桃问题)
R language uses GLM function to build Poisson logarithm linear regression model, processes three-dimensional contingency table data to build saturation model, uses step function to realize stepwise re
Basic usage and principle of fork/join framework
Jerry added an input capture channel [chapter]
Interview shock 60: what will cause MySQL index invalidation?
How to modify a node_ Files in modules
Unity shader learning (II) the first shader
