Note:
This topic has been translated from a Chinese forum by GPT and might contain errors.
Original topic: DM同步数据,外键类型不兼容怎么处理?
The foreign key type is varchar(32), and the referenced type is char(32). Don’t ask me why the original table is like this;
Using DM to synchronize data, it reports an error saying they are incompatible;
How to handle this? I deleted all the foreign keys in the original table, but the task still reports an error; it should be that DM has already pulled the information and will not pull the modified table structure again.
You can use dmctl binlog-schema
to modify the mapping of the table structure.
Remove the foreign key and resynchronize.
Try synchronizing in batches according to the ER diagram of the foreign key table.
I think you can try restarting and then syncing again.
When using the DM (Data Migration) tool for data synchronization, if you encounter issues with incompatible foreign key types, it is indeed because DM has recorded the original table structure. Even if the table structure is modified later, DM will not automatically update this information. To resolve this issue, you can follow these steps:
- Stop the DM task: First, ensure that you have stopped the ongoing data synchronization task.
- Clean up metadata: DM will create a database named
dm_meta
in the upstream MySQL instance to store metadata for synchronization tasks. You need to manually clean up this metadata so that DM can re-read the table structure.
Then it can only be removed.
DM’s synchronization support for foreign keys is not very good. If it really can’t be handled, get the latest binlog and create a new task to resynchronize.
After removing the foreign key, you can try resetting the data migration task.
When an exception occurs during the data migration process and it cannot be recovered, you need to reset the data migration task and re-migrate the data:
- Use
stop-task
to stop the abnormal data migration task.
- Clean up the data that has been migrated downstream.
- Choose one of the following two methods to restart the data migration task:
- Modify the task configuration file to specify a new task name, then use
start-task {task-config-file}
to restart the migration task.
- Use
start-task --remove-meta {task-config-file}
to restart the data migration task.
Remove foreign keys, foreign keys are not supported during import.
In the end, it was done this way, but you need to delete dm_meta.
Basically, this is how it’s done: initially, stop the task, delete the already synchronized data, and then create a new task (with a different name, otherwise it will still report an error). Later, I found out that deleting dm_meta should allow a complete restart. Additionally, at the beginning, the foreign keys were not completely cleaned up, and during the process, I encountered the issue again, so I had to create a new task.