TiCDC v7.5.1 创建同步kafka任务报index not found when verify the table错误

一个好的问题描述有利于社区小伙伴更快帮你定位到问题,高效解决你的问题

【TiDB 使用环境】生产环境
【TiDB 版本】TiDB v7.5.1
【部署方式】机器部署
【操作系统/CPU 架构/芯片详情】
【机器部署详情】CPU大小/内存大小/磁盘大小
【集群数据量】
【集群节点数】
【问题复现路径】创建TiCDC同步任务,同步到kafka,kafka版本为:2.6.1
【遇到的问题:问题现象及影响】
创建同步任务时报:index not found when verify the table
确认表是存在主键的,最近也没有做过DDL操作。
【资源配置
【复制黏贴 ERROR 报错的日志】
创建changefeed命令:

cdc cli changefeed create --server=****:*** --sink-uri="kafka://***:9092/***?protocol=canal-json&kafka-version=2.6.1&partition-num=3&max-message-bytes=67108864&replication-factor=3" --changefeed-id=sbtest --start-ts=0 --no-confirm=true --config changefeed.toml

cdc.log

[2026/05/27 08:45:52.875 +00:00] [INFO] [pd_service_discovery.go:632] ["[pd] switch leader"] [new-leader=http://****:****] [old-leader=]
[2026/05/27 08:45:52.875 +00:00] [INFO] [pd_service_discovery.go:197] ["[pd] init cluster id"] [cluster-id=7644488402582993315]
[2026/05/27 08:45:52.876 +00:00] [INFO] [client.go:600] ["[pd] changing service mode"] [old-mode=UNKNOWN_SVC_MODE] [new-mode=PD_SVC_MODE]
[2026/05/27 08:45:52.876 +00:00] [INFO] [tso_client.go:230] ["[tso] switch dc tso global allocator serving address"] [dc-location=global] [new-address=http://****:***]
[2026/05/27 08:45:52.880 +00:00] [INFO] [tso_dispatcher.go:318] ["[tso] tso dispatcher created"] [dc-location=global]
[2026/05/27 08:45:52.880 +00:00] [INFO] [client.go:648] ["[pd] service mode changed"] [old-mode=UNKNOWN_SVC_MODE] [new-mode=PD_SVC_MODE]
[2026/05/27 08:45:52.880 +00:00] [ERROR] [tso_dispatcher.go:557] ["[tso] update connection contexts failed"] [dc=global] [error="rpc error: code = Canceled desc = context canceled"]
[2026/05/27 08:45:52.880 +00:00] [INFO] [tso_dispatcher.go:339] ["[tso] exit tso dispatcher"] [dc-location=global]
[2026/05/27 08:45:52.880 +00:00] [INFO] [tso_dispatcher.go:240] ["exit tso dispatcher loop"]
[2026/05/27 08:45:52.880 +00:00] [INFO] [tso_dispatcher.go:186] ["exit tso requests cancel loop"]
[2026/05/27 08:45:52.880 +00:00] [INFO] [pd_service_discovery.go:248] ["[pd] exit member loop due to context canceled"]
[2026/05/27 08:45:52.880 +00:00] [WARN] [resource_manager_client.go:326] ["[resource_manager] get token stream error"] [error="rpc error: code = Canceled desc = context canceled"]
[2026/05/27 08:45:52.880 +00:00] [INFO] [resource_manager_client.go:314] ["[resource manager] exit resource token dispatcher"]
[2026/05/27 08:45:52.880 +00:00] [INFO] [tso_client.go:134] ["closing tso client"]
[2026/05/27 08:45:52.880 +00:00] [INFO] [tso_client.go:139] ["close tso client"]
[2026/05/27 08:45:52.880 +00:00] [INFO] [tso_client.go:150] ["tso client is closed"]
[2026/05/27 08:45:52.880 +00:00] [INFO] [pd_service_discovery.go:294] ["[pd] close pd service discovery client"]
[2026/05/27 08:45:52.884 +00:00] [INFO] [region_cache.go:2658] ["change store resolve state"] [store=1] [addr=****:***] [from=unresolved] [to=resolved] [liveness-state=reachable]
[2026/05/27 08:45:52.886 +00:00] [INFO] [region_cache.go:2658] ["change store resolve state"] [store=4] [addr=****:***] [from=unresolved] [to=resolved] [liveness-state=reachable]
[2026/05/27 08:45:52.888 +00:00] [INFO] [region_cache.go:2658] ["change store resolve state"] [store=13] [addr=****:***] [from=unresolved] [to=resolved] [liveness-state=reachable]
[2026/05/27 08:45:52.903 +00:00] [INFO] [middleware.go:49] [/api/v2/verify_table] [status=500] [method=POST] [path=/api/v2/verify_table] [query=] [ip=****] [user-agent=Go-http-client/1.1] [client-version=v7.5.1] [error="[CDC:ErrDispatcherFailed]index not found when verify the table, table: sbtest.sbtest1, index: "] [error="[CDC:ErrDispatcherFailed]index not found when verify the table, table: sbtest.sbtest1, index: "] [errorVerbose="[CDC:ErrDispatcherFailed]index not found when verify the table, table: sbtest.sbtest1, index: \ngithub.com/pingcap/errors.AddStack\n\tgithub.com/pingcap/errors@v0.11.5-0.20221009092201-b66cddb77c32/errors.go:174\ngithub.com/pingcap/errors.(*Error).GenWithStack\n\tgithub.com/pingcap/errors@v0.11.5-0.20221009092201-b66cddb77c32/normalize.go:155\ngithub.com/pingcap/tiflow/cdc/sink/dmlsink/mq/dispatcher.(*EventRouter).VerifyTables\n\tgithub.com/pingcap/tiflow/cdc/sink/dmlsink/mq/dispatcher/event_router.go:140\ngithub.com/pingcap/tiflow/cdc/api/v2.APIV2HelpersImpl.getVerifiedTables\n\tgithub.com/pingcap/tiflow/cdc/api/v2/api_helpers.go:523\ngithub.com/pingcap/tiflow/cdc/api/v2.(*OpenAPIV2).verifyTable\n\tgithub.com/pingcap/tiflow/cdc/api/v2/changefeed.go:360\ngithub.com/gin-gonic/gin.(*Context).Next\n\tgithub.com/gin-gonic/gin@v1.8.1/context.go:173\ngithub.com/pingcap/tiflow/cdc/api/v2.RegisterOpenAPIV2Routes.ErrorHandleMiddleware.func3\n\tgithub.com/pingcap/tiflow/cdc/api/middleware/middleware.go:65\ngithub.com/gin-gonic/gin.(*Context).Next\n\tgithub.com/gin-gonic/gin@v1.8.1/context.go:173\ngithub.com/pingcap/tiflow/cdc/api/v2.RegisterOpenAPIV2Routes.LogMiddleware.func2\n\tgithub.com/pingcap/tiflow/cdc/api/middleware/middleware.go:39\ngithub.com/gin-gonic/gin.(*Context).Next\n\tgithub.com/gin-gonic/gin@v1.8.1/context.go:173\ngithub.com/pingcap/tiflow/cdc/api/v2.RegisterOpenAPIV2Routes.CheckServerReadyMiddleware.func1\n\tgithub.com/pingcap/tiflow/cdc/api/middleware/middleware.go:179\ngithub.com/gin-gonic/gin.(*Context).Next\n\tgithub.com/gin-gonic/gin@v1.8.1/context.go:173\ngithub.com/gin-gonic/gin.CustomRecoveryWithWriter.func1\n\tgithub.com/gin-gonic/gin@v1.8.1/recovery.go:101\ngithub.com/gin-gonic/gin.(*Context).Next\n\tgithub.com/gin-gonic/gin@v1.8.1/context.go:173\ngithub.com/gin-gonic/gin.(*Engine).handleHTTPRequest\n\tgithub.com/gin-gonic/gin@v1.8.1/gin.go:616\ngithub.com/gin-gonic/gin.(*Engine).ServeHTTP\n\tgithub.com/gin-gonic/gin@v1.8.1/gin.go:572\nnet/http.serverHandler.ServeHTTP\n\tnet/http/server.go:2938\nnet/http.(*conn).serve\n\tnet/http/server.go:2009\nruntime.goexit\n\truntime/asm_amd64.s:1650"] [duration=31.732512ms]

changefeed.toml

case-sensitive = true

force-replicate = true

[filter]
ignore-txn-start-ts = [1, 2]
rules = [ 'sbtest.*']

[mounter]
worker-num = 16

[sink]
dispatchers = [
    {matcher = ['*.*'],  partition = "index-value"}
]

sbtest.sbtest1 表结构

 sbtest1 | CREATE TABLE `sbtest1` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `k` int(10) unsigned NOT NULL DEFAULT '0',
  `c` char(120) NOT NULL DEFAULT '',
  `pad` char(60) NOT NULL DEFAULT '',
  PRIMARY KEY (`id`) /*T![clustered_index] CLUSTERED */,
  KEY `k_1` (`k`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin AUTO_INCREMENT=605907

【其他附件:截图/日志/监控】

PRIMARY KEY (id) /*T![clustered_index] CLUSTERED */,
KEY k_1 (k)
key和primary key是一回事么

我的问题是表有主键,为什么ticdc还会报没有有效索引。
同一张表同步TiDB可以,同步kafka时为什么就报错。

index not found when verify the table, table: test.t1, index: "

是不是因为 test.t1 没有有效 index?

是sbtest.sbtest1表,这张表是有主键的

有主键就一定有索引,作为一个索引,明明是索引。ticdc不认可它。明明很伤心

主键是 非聚簇索引 NONCLUSTERED(老版本 TiCDC 不认)
主键列 允许 NULL(违反规则)
主键包含 虚拟列(generated column)
主键是 表达式索引(TiCDC 不支持)
表结构元数据损坏
主键 被隐藏 invisible
TiCDC 读取的 schema 信息是旧的、缓存的

同步到 TiDB 正常、同步到 Kafka 报错,是因为 TiCDC 在同步到 Kafka 时需要依赖索引来构建消息的分区键(partition = "index-value"),对索引的校验更严格。

聚簇主键(CLUSTERED PRIMARY KEY)在 TiDB 中是合法的主键,但 v7.5.1 版本的 TiCDC 对其支持不完善,导致误判。

1 个赞

此话题已在最后回复的 7 天后被自动关闭。不再允许新回复。