【 TiDB 使用环境】测试
【 TiDB 版本】8.5.1
【遇到的问题:问题现象及影响】
8.5.0版本PD模块的Active PD Followe正式GA了,这提升了pd的高并发请求处理能力,使用整个TiDB集群性能也更加稳定。但有个疑问,与 PD Follower通讯的客户端怎么判断从pd上获取的信息,比如region是最新的(跟leader一样)。这一块的请求流程和处理逻辑能否讲解下。谢谢!
1 个赞
https://github.com/tikv/pd/issues/7431
Specifically, if the caller wants to obtain a new region first time, it can do so from the followers (we can assume that most of the region information in the followers is up to date). If the caller needs to update the region information, we think that this time must get the latest, then this time from the leader.
According to above additional knowledge, this transformation is very easy to do in client-go.
design这一段里面是这样写的。
大致是说,假设第一次获取region信息,从follower上取。但是当需要更新这个region的信息到最新的情况下,就必须从leader上取。
而且这个情况的判断是在client-go里面维护的。
感觉用常见的应用开发类比,可以理解为follower是缓存,leader是数据库。读取优先从缓存读,当发现缓存读取的数据不符合预期再去数据库里读一次。大致是这么个意思。
1 个赞
谢谢!看了下。如果客户端的当前调用必须获取最新的region信息,请求还是leader。
1 个赞
这个解释通俗易懂。