DM replication error: Both tables have the same structure, but still report "Column count doesn't match value count: 2 (columns) vs 3 (values)"

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

Original topic: dm复制报错,两个表结构一样,也报Column count doesn’t match value count: 2 (columns) vs 3 (values)

| username: 路在何chu

[TiDB Usage Environment] Production / Testing / PoC
[TiDB Version]
[Reproduction Path] Operations performed that led to the issue
Executed on MySQL side:
ALTER TABLE t3 ADD COLUMN new_col INT UNIQUE;
dm error
“Message”: “startLocation: [position: (, 0), gtid-set: ], endLocation: [position: (mysql-bin.000003, 1850), gtid-set: 33fe3796-a10b-11ed-ab4a-000c29acdd18:1-16]: gen insert sqls failed, sourceTable: test.t3, targetTable: test.t3: Column count doesn’t match value count: 2 (columns) vs 3 (values)”,
“RawCause”: “”,

Executed skip operation:
tiup dmctl --master-addr 10.0.0.75:8261 handle-error alldb skip

Manually executed on tiup:
ALTER TABLE t3 ADD COLUMN new_col INT;
ALTER TABLE t3 ADD UNIQUE(new_col);
MySQL side insert statement error:
insert into t3 values(6,‘dddd’,1);
Checked that the table structures on both sides are consistent

| username: tidb菜鸟一只 | Original post link

What error is being reported now after skipping this error?

| username: 路在何chu | Original post link

How to skip this?

| username: redgame | Original post link

tiup dmctl --master-addr 10.0.0.75:8261 handle-error alldb skip

| username: 有猫万事足 | Original post link

I didn’t understand the question. The error says that the upstream and downstream table structures are inconsistent, one has 2 columns and the other has 3 columns.
Generally, you just need to compare the table structures to see where the discrepancy is, alter the table to keep the number of columns consistent between upstream and downstream, and then resume the task to continue.
It’s not necessary to skip.
Skipping might lead to data inconsistency between upstream and downstream.

| username: tony5413 | Original post link

It seems that both sides are already inconsistent and need to be redone.

| username: 路在何chu | Original post link

This is to skip DDL errors.

| username: 路在何chu | Original post link

I have already modified the table structure to be consistent on both sides, but then the insert operation reported an error.

| username: 有猫万事足 | Original post link

It might be historical SQL.

Is it a production environment? If it is production data, it is best to stop the task, delete the four tables corresponding to this task under the dm_meta database, and completely clean up the downstream data before re-importing. Because even if you skip the erroneous SQL, it may lead to inconsistencies between upstream and downstream, which could be unacceptable in a production environment.

If it is a test environment or consistency is not highly required, you can choose to skip the SQL through commands.

| username: 有猫万事足 | Original post link

If the table is very large and you don’t want to rebuild the entire task, and you must perform incremental repair, you can use this MySQL command-line tool to check the SQL statements at the corresponding positions in the binlog file. Then, based on this, repair the downstream table to ensure that the two are consistent. The SQL in the binlog can then be executed smoothly.

| username: 路在何chu | Original post link

It might be a bug. Upgrading to 6.5 resolves the issue, and performing the same operation no longer results in an error.

| username: onlyacat | Original post link

Operate the schema to see if the schema cached in DM is inconsistent or outdated.

| username: 路在何chu | Original post link

The upgrade has been completed, so there’s no need to set up a lower version again. If this error occurs again in the future, you can troubleshoot it following this approach. Thank you.

| username: system | Original post link

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