How to Obtain Data Synchronization Latency Information between TiFlash and TiKV in TiDB

This topic has been translated from a Chinese forum by GPT and might contain errors.

Original topic: TIDB 如何获取TiFlash与TIKV数据同步延迟信息

| username: residentevil

[TiDB Usage Environment] Production Environment
[TiDB Version] V6.5.8
[Encountered Problem: Problem Phenomenon and Impact] Is there a way to monitor the data synchronization delay between TiKV and TiFlash? I couldn’t find it in the community documentation. Could any expert please provide some guidance?

| username: xfworld | Original post link

Checking this should be enough:

If synchronization is slow, you need to troubleshoot. I recommend looking here:

| username: redgame | Original post link

Gained something.

| username: 小于同学 | Original post link

Learned a lot, thanks for sharing.

| username: residentevil | Original post link

Sorry, I might not have explained it clearly. Actually, it’s not about the speed of building TiFlash. I want to know if there will be cases where data cannot be queried from TiFlash within XXms after being written online. Based on this situation, is it possible to check the data synchronization delay from TiKV to TiFlash?

| username: chenhanneu | Original post link

The query result will only be returned after all the data before the query time has been synchronized to TiFlash.

| username: residentevil | Original post link

Has this been tested?

| username: TiDBer_aaO4sU46 | Original post link

We haven’t tested it.

| username: Kongdom | Original post link

I can learn new things from the experts every day.

| username: zhanggame1 | Original post link

This is covered in the official course, including how TiFlash synchronizes and catches up with the query TSO.

| username: residentevil | Original post link

So there is actually still some latency here, but it’s unclear how significant the latency is.

| username: zhanggame1 | Original post link

The official statement says that the copy efficiency is very high.

| username: 小龙虾爱大龙虾 | Original post link

Details of Region replication cannot be viewed, but consistency in reading can be guaranteed. If not synchronized, it will wait.

| username: FutureDB | Original post link

It seems that there is no specific monitoring mentioned, but the synchronization from TiKV to TiFlash is asynchronous, so there is definitely some delay. The official documentation states that the delay is relatively small, and TiFlash can ensure consistent reads.

Whenever a read request is received, the Region replica in TiFlash will initiate a progress check with the Leader replica (a very lightweight RPC request). The read response is only sent after ensuring that the progress covers at least the data up to the timestamp of the read request.


| username: residentevil | Original post link

This part still needs further testing.

| username: FutureDB | Original post link

Sure, you can perform a stress test.