Can CDC support data subscription for TiDB tables without primary keys?

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

Original topic: cdc能否支持tidb无主键表数据订阅?

| username: TiDBer_DP2LpWTB

【TiDB Usage Environment】Testing
【TiDB Version】
【Reproduction Path】Create a table without PK and UK in TiDB
【Encountered Problem: Problem Description and Impact】CDC cannot capture data from tables without primary keys
【Resource Configuration】
【Attachments: Screenshots/Logs/Monitoring】

| username: 小龙虾爱大龙虾 | Original post link

No, it will cause data inconsistency between upstream and downstream.

| username: 像风一样的男子 | Original post link

  • Tables synchronized by TiCDC need to have at least one valid index, defined as follows:
    • A primary key (PRIMARY KEY) is a valid index.
    • A unique index (UNIQUE INDEX) is valid if each column is explicitly defined as non-null (NOT NULL) in the table structure and there are no virtual generated columns (VIRTUAL GENERATED COLUMNS).
| username: FutureDB | Original post link

The official documentation states that a primary key or unique key is required. You can check it here: TiCDC 简介 | PingCAP 文档中心

| username: 江湖故人 | Original post link

If there is no primary key or unique key, only full table synchronization can be performed, and row-level incremental synchronization is not possible.
Try to implement a cross-database synchronization function using a stored procedure, and you will understand the reasoning behind it.

| username: Soysauce520 | Original post link

It is not supported. Such table creation DDL without primary keys and non-null unique indexes cannot be synchronized.

| username: Daniel-W | Original post link

Tables without primary keys or unique keys will be considered ineligible, and CDC will not perform synchronization.

| username: 烂番薯0 | Original post link

At least one primary key or a non-null unique key is required.

| username: dba远航 | Original post link

Not supported, there must be at least one primary key or a non-null unique key.

| username: andone | Original post link

Not supported, a primary key is required.

| username: TiDBer_DP2LpWTB | Original post link

Tables without primary keys in TiDB have their own rowid, right? Can’t CDC output the rowid? Handling it should be a downstream issue, but not outputting it directly seems a bit unreasonable.