DM 同步中报错 duplicate entry

DM 同步中报错 duplicate entry,参考官方文档,未得到有效信息,询问大家是否遇到过类似的问题

DM 任务配置如下:
name: xxx
task-mode: all
is-sharding: false
shard-mode: pessimistic
strict-optimistic-shard-mode: false
ignore-checking-items:
meta-schema: dba_dm_meta
enable-heartbeat: false
heartbeat-update-interval: 1
heartbeat-report-interval: 10
timezone: “”
case-sensitive: false
collation_compatible: strict
target-database:
host: 10.xx.xx.xx
port: 3306
user: xxxx
password: ‘******’
max-allowed-packet: null
session:
collation_database: utf8mb4_general_ci
sql_require_primary_key: “0”
tidb_txn_mode: optimistic
security: null
mysql-instances:

  • source-id: mysql_source
    meta: null
    filter-rules:
    column-mapping-rules:
    route-rules:
    expression-filters:
    black-white-list: “”
    block-allow-list: balist-01
    mydumper-config-name: dump-01
    mydumper: null
    mydumper-thread: 0
    loader-config-name: load-01
    loader: null
    loader-thread: 0
    syncer-config-name: sync-01
    syncer: null
    syncer-thread: 0
    validator-config-name: validator-01
    online-ddl: true
    shadow-table-rules:
    trash-table-rules:
    online-ddl-scheme: “”
    routes: {}
    filters: {}
    column-mappings: {}
    expression-filter: {}
    black-white-list: {}
    block-allow-list:
    balist-01:
    do-tables:
    do-dbs:
    • db1
    • db2
    • db3
    • db4
    • db5
    • db6
    • db7
      ignore-tables:
      ignore-dbs:
      mydumpers:
      dump-01:
      mydumper-path: ./bin/mydumper
      threads: 4
      chunk-filesize: “64”
      statement-size: 0
      rows: 0
      where: “”
      skip-tz-utc: true
      extra-args: “”
      loaders:
      load-01:
      pool-size: 16
      dir: ./dumped_data
      sorting-dir-physical: ./dumped_data.uac.sorting
      import-mode: logical
      on-duplicate: “”
      on-duplicate-logical: replace
      on-duplicate-physical: none
      disk-quota-physical: 0
      checksum-physical: required
      analyze: optional
      range-concurrency: 0
      compress-kv-pairs: “”
      pd-addr: “”
      syncers:
      sync-01:
      meta-file: “”
      worker-count: 16
      batch: 100
      queue-size: 1024
      checkpoint-flush-interval: 30
      compact: false
      multiple-rows: false
      max-retry: 0
      auto-fix-gtid: false
      enable-gtid: false
      disable-detect: false
      safe-mode: false
      safe-mode-duration: 60s
      enable-ansi-quotes: false
      validators:
      validator-01:
      mode: none
      worker-count: 4
      validate-interval: 10s
      check-interval: 5s
      row-error-delay: 30m0s
      meta-flush-interval: 5m0s
      batch-query-size: 100
      max-pending-row-size: 500m
      max-pending-row-count: 2147483647
      clean-dump-file: true
      ansi-quotes: false
      remove-meta: false
      experimental:
      async-checkpoint-flush: false

查下 dm 的日志 看看冲突的数据是哪些,

就是主键冲突,表上唯一约束的只有主键,没有其他唯一约束,错误信息中,冲突提示的主键在下游表中确实是存在的,下游tidb 8.1,仅用于dm迁移验证,没有任何数据写入
上游为mysql 8.0.23,GTID开启,主从复制的从库(只读+log_slave_updates=on)

造成这个问题的原因是什么呢?delete 没同步到?如果不想关心这个问题,只想让dm执行过去的,并覆盖掉原来的数据的话,可以使用安全模式。

https://docs.pingcap.com/zh/tidb/stable/dm-safe-mode

主键冲突呀

大概率是主键冲突问题,先检测下上游表数据情况,然后再恢复任务试试

binlog同步的,下游也没操作,所以不知道为什么会冲突,似乎也没有跳过DML的方法

@麻辣机师 有试试这个 safe mode 来解决这个问题么?

sade_mode应该能,但又担心上下游数据不一致