问题描述:
AWS DMS去执行一个表的fullload+cdc任务,但是很多次莫名发现这个表报错,而且是一开始没有报错,后续会报错。报错信息就是列数不匹配。
报错信息:
00713562: 2024-07-11T15:40:07 [SOURCE_CAPTURE ]W: Mismatch number of columns in table test.test1: CDC event has 5 columns while Replicate knows 4. Only the first 4 columns will be replicated. This may imply that DDL changes were done and reverted when the task did not run. (mysql_endpoint_capture.c:1496)
00713562: 2024-07-11T15:40:07 [SOURCE_CAPTURE ]W: Error parsing column 'col1' in table 'test1' - overflow occurred (mysql_endpoint_capture.c:2795)
00713562: 2024-07-11T15:40:07 [DMS_INTERNAL ]I: Event (first 2048 bytes):
00713562: 2024-07-11T15:40:07 [SOURCE_CAPTURE ]W: Suspending table 'test1', table id '34' (mysql_endpoint_capture.c:1770)
00713522: 2024-07-11T15:40:07 [TASK_MANAGER ]W: Table 'test'.'test1' was errored/suspended (subtask 0 thread 0). (replicationtask.c:3045)
分析过程 及 解决方案:
表面上,出现这个报错,大家就不会从报错继续往下查了,一般就认为是我们自己无意中在源端或者目标端更改了table DDL,源端增加或者目标端去掉了一列。
但是其实问题不是这么简单,哪怕选择reload任务表也还是会出错。
那么如何深入排查呢?
是这样:通过这个表的名字,比如test.test1, 搜索一下日志。会发现如下一个报错,还是个warning, 不是error:
00722269: 2024-07-11T07:41:56 [SOURCE_UNLOAD ]W: Column 'col1' was removed from table definition 'test.test1': the column data type is LOB and the table has no primary key or unique index (metadatamanager.c:3105)
通过这个报错,查看这个DMS任务的设置,发现任务的LOB部分确实是设置成LimitedSizeLobMode
AWS有个博客上这样写了,不在官方文档里:
Full load and CDC: Require primary key (otherwise remove LOB column for both full load and CDC phase if no primary key)
所以,这个问题的原因很简单,就是DMS任务源端的这张表里有LOB字段,同时还没有Primary Key,所以在目标端就被drop了,DMS迁移任务是首先迁移没有LOB字段的列的,因此DMS任务启动以后的一段时间内这个表不会报错,但是终究还是会因为LOB列被drop而报错。