Background
TiCDC allows replicating data from an upstream TiDB cluster to a downstream system, including another TiDB cluster. However, using the same TiDB cluster as both the upstream and downstream can cause unexpected replication issues, including feedback loops and data inconsistencies.
To prevent this, we need a mechanism to reliably determine whether the upstream and downstream TiDB clusters are the same and reject such configurations.
Proposed Solution
We will use the Cluster ID stored in TiDB’s system table(mysql.tidb) to compare the upstream and downstream clusters.
-
Retrieve Upstream Cluster ID
- TiCDC already obtains the upstream Cluster ID via PD’s gRPC API.
-
Retrieve Downstream Cluster ID
- TiDB will introduce a system table
mysql.tidb to store the Cluster ID.
- TiCDC will query this system table via SQL to fetch the downstream Cluster ID.
-
Comparison and Validation
- If the upstream and downstream Cluster IDs match, TiCDC will reject the changefeed creating, updating and resuming with an appropriate error message.
Tasks
Background
TiCDC allows replicating data from an upstream TiDB cluster to a downstream system, including another TiDB cluster. However, using the same TiDB cluster as both the upstream and downstream can cause unexpected replication issues, including feedback loops and data inconsistencies.
To prevent this, we need a mechanism to reliably determine whether the upstream and downstream TiDB clusters are the same and reject such configurations.
Proposed Solution
We will use the Cluster ID stored in TiDB’s system table(
mysql.tidb) to compare the upstream and downstream clusters.Retrieve Upstream Cluster ID
Retrieve Downstream Cluster ID
mysql.tidbto store the Cluster ID.Comparison and Validation
Tasks
mysql.tidband retrieve the downstream Cluster ID.