Data Migration from TiDB v5.2.1 to TiDB v6.1.2 Using BR+CDC Results in Auto-Increment Primary Key Conflicts

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

Original topic: 通过BR+CDC 迁移数据 从Tidbv5.2.1 到 Tidbv6.1.2 出现自增主键表 主键冲突

| username: xiaoyang1999

Bug Report
Clearly and accurately describe the issue you found. Providing any steps to reproduce the problem can help the development team address it promptly.
[TiDB Version] v5.2.1 → v6.1.2
[Impact of the Bug]
Primary key conflict

[Possible Steps to Reproduce the Issue]
Disable GC, backup and restore full data using BR
Enable TiCDC to start incremental synchronization, disable GC
Shut down the old version and officially switch to the new version

[Observed Unexpected Behavior]
Primary key conflict, the AUTO_INCREMENT value recorded on the table is incorrect, causing TiDB to continuously encounter primary key conflicts when inserting data

[Expected Behavior]

| username: xiaoyang1999 | Original post link

I hope there is a way to quickly refresh the sequence cache and simultaneously correct AUTO_INCREMENT.

| username: h5n1 | Original post link

Directly updating AUTO_INCREMENT, the autoid cache currently seems to only be refreshed by restarting the TiDB server.

| username: mayjiang0203 | Original post link

Given the product limitations, there is a conflict issue between explicit insertion and implicit allocation. TiCDC uses explicit insertion, while the default insert uses implicit allocation.
Issue recorded here: Using auto_increment id as a unique key will be duplicated in some cases · Issue #2285 · pingcap/tidb · GitHub
Official documentation:
AUTO_INCREMENT | PingCAP 文档中心
We will consider enhancing TiCDC to avoid this issue or supplementing the TiCDC usage documentation to add an explanation of this issue.

Currently, it is recommended to avoid this issue by using the following SQL or restarting TiDB.

alter table ... auto_increment 0
| username: system | Original post link

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.