[TiDB Usage Environment] Production Environment / Testing / PoC
[TiDB Version]
[Reproduction Path] What operations were performed when the issue occurred
[Encountered Issue: Issue Phenomenon and Impact]
[Resource Configuration]
[Attachments: Screenshots / Logs / Monitoring]
Dear teachers, when using ticdc to synchronize data from one TiDB cluster to another TiDB cluster or Kafka, the start-ts is required when starting the changefeed. How can I obtain the current TSO of the TiDB cluster to use as the start-ts? Is there any command for this?
If you want to use the current TiDB backup to set up a new TiDB cluster, there are two methods:
Dumpling + TiDB-Lightning method: Similar to mydumper, you can find the TSO at the time of backup in the meta file of dumpling.
BR backup + BR restore method: After a successful BR backup, you can find the TSO value in the standard output.
If you only want to synchronize the latest data to the new cluster and do not care about historical data, you can use the current timestamp (in milliseconds) and shift it left by 18 bits to get the current TSO value.
MySQL []> select REPLACE(unix_timestamp(current_timestamp(3)),'.','') <<18 as current_tso;
+--------------------+
| current_tso |
+--------------------+
| 438595539700809728 |
+--------------------+
1 row in set (0.000 sec)
According to the official documentation, TSO is a timestamp that represents a point in time. If you need to start synchronization from the current point, it doesn’t matter whether it’s the TSO of a transaction or the cluster; you can just choose a point in time. Any changes made by transactions greater than this TSO will be synchronized. (Of course, as mentioned above, for your scenario, you can simply not specify start-ts.)
TSO stands for Time Stamp Oracle, which is a monotonically increasing timestamp provided by PD (Placement Driver) for each transaction.