TiDB 4.0.12, Cluster Primary-Secondary Switch

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

Original topic: tidb 4.0.12 ,集群主备切换

| username: hnairdb

tidb 4.0.12

initial-commit-ts
Specifies the transaction commit timestamp (commit ts) from which to start synchronization. This configuration is only applicable to Drainer nodes that are starting synchronization for the first time.
If a checkpoint already exists downstream, synchronization will proceed based on the time recorded in the checkpoint.
The commit ts (commit timestamp) is the transaction commit time in TiDB.
This timestamp is a globally unique, incrementing timestamp obtained from PD, serving as the unique ID for the current transaction. A typical initial-commit-ts configuration can be obtained in the following ways:

  • The backup TS recorded in the metadata (backupmeta) of a BR backup
  • The Pos recorded in the metadata of a Dumpling backup
  • The result returned by the tso command in PD Control
    Default: -1. Drainer will obtain the latest timestamp from PD as the initial time, meaning synchronization will start from the current time.

drainer_servers:

  • host: 10.0.1.12
    port: 8249
    data_dir: “/tidb-data/drainer-8249”
    commit_ts: -1
    deploy_dir: “/tidb-deploy/drainer-8249”
    config:

Conclusion: In the absence of a checkpoint, commit_ts will be used. Therefore, deleting the checkpoint can avoid duplicate data or primary key conflicts.

Question: When using Drainer for synchronization, when is the checkpoint updated? Or is the checkpoint never updated? How to check the master-slave synchronization status?

| username: jansu-dev | Original post link

  1. When is the checkpoint updated? Or will the checkpoint not be updated?
    The checkpoint is the schema and table written by the drainer in the downstream, which records the time point to which the drainer has synchronized to the downstream. The drainer will update when a new txn is successfully synchronized to the downstream. Another situation is that there may be no txn in the upstream for a long time, in which case the drainer will write a fake binlog to the downstream every 3 seconds, and the checkpoint will also be updated at this time.

  2. How to check the master-slave synchronization status?
    The drainer monitoring panel contains various statuses of the drainer.