How to handle the error `duplicate entry` when DM is replicating data?

You need to first check and confirm the following things:

  • disable-detect is not configured in the replication task ( in v2.0.7 and earlier versions).
  • The data is not inserted manually or by other replication programs.
  • No DML filter associated with this table is configured.

To facilitate troubleshooting, you can first collect general log files of the downstream TiDB instance and then ask for technical support at TiDB Community slack channel. The following example shows how to collect general log files: