DM Automatically Ignores TRUNCATE Statements

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

Original topic: dm自动忽略truncate语句

| username: tuyi锅子

【TiDB Version】6.1.0
【Encountered Issue】DM automatically ignores truncate statements
【Issue Phenomenon and Impact】
Using DM to synchronize MySQL data to TiDB, a primary key conflict is prompted. Upon checking the binlog, it is found that MySQL first truncates the table and then reinserts the data. At this point, the DM task reports a primary key conflict and synchronization is interrupted. The DM task configuration file does not configure events: [“truncate table”, “drop table”], and the user being used has all permissions.

| username: lance6716 | Original post link

Currently, DM will internally block TRUNCATE statements.

We will track this requirement at DM should sync `TRUNCATE TABLE` statement to downstream · Issue #5055 · pingcap/tiflow · GitHub

| username: tuyi锅子 | Original post link

Is there any way to avoid this now? We often encounter primary key conflicts caused by this issue.

| username: lance6716 | Original post link

You can try enabling the safe-mode option in the task configuration. This way, new data with the same primary key will overwrite the old data. However, old data that hasn’t been overwritten still cannot be automatically deleted.

| username: tuyi锅子 | Original post link

Okay, thank you, I’ll give it a try.

| username: system | Original post link

This topic was automatically closed 60 days after the last reply. No new replies are allowed.