Thank you both for your replies. I have learned a lot, but I still have some questions. I have drawn a diagram.
Assume there are three nodes A, B, and C, and a full backup was done at T1.
Then at T2, there are three distributed transactions TD1, TD2, and TD3, with their respective start ts and commit ts shown in the diagram.
The first question is: When TiDB performs PiTR, does each node’s binlog recovery specify commit ts to restore the logs? Or is it similar to MySQL’s binlog where you can only specify position or local timestamp to restore?
In the first question, if it specifies commit ts to restore, then it requires the distributed transaction on each node to merge the logs in the binlog into a complete transaction like TD1, TD2, TD3 for log loading. Is this how it is implemented?
If it is similar to MySQL where you specify the local position/ts to restore, then it must ensure that the ts obtained by PD is processed first, and other transactions can only be committed after this transaction is successfully committed. Otherwise, TD1, TD2, and TD3 will not be in order but in a disorderly manner.
In this case, I can easily simulate a transaction TD1. After obtaining commit ts=ts2 on node B, it completes normally, and the local ts of node B is also ts2 (NTP ensures that the time between nodes is consistent, but there can still be more than 200ms of error). However, on node A, for some reason, the local commit ts of TD1 is not ts2 but may be ts8 or later.
At this time, if we use PiTR to specify a point in time ts2 to load the logs, node B will almost normally load the transaction TD1, but node A will inevitably miss it because the local commit ts of TD1 is ts8, causing TD1 to appear on node B but not on node A during PiTR.
In @maxshuang’s reply, I understand that this is handled at the backup time point, but is it also handled this way during PiTR? Because PiTR definitely only loads logs.
In @IANTHEREAL’s reply, I understand that you want to get a global checkpoint ts, but if it is only derived from the smallest local commit ts of each node without considering which nodes are involved in all distributed transactions at that time, it will still result in inconsistencies in the recovery of some distributed transactions.