All Products
Search
Document Center

A prompt "Duplicate entry: XXXX" appears when you use the new version of the DMS console to make changes.

Last Updated: Feb 08, 2021

Overview

An error similar to the following is reported when you use the new version of the DMS console to change the data of an apsaradb RDS for MySQL instance or a user-created MySQL database (either an ECS-hosted database or a user-created database in an IDC).

Duplicate entry: XXXX

Detail

Problem description Cause Solution
This issue occurs when you use the data change feature for DML operations (insert, update). The unique constraint or index that exists in the table already has corresponding data.

Confirm the rationality of the unique constraint or unique index, and whether the existing unique key value data of the instance is reasonable (whether the data can be cleaned). If all are reasonable, confirm whether the current requirements can be adjusted.

This issue occurs when you use the schema design feature to perform DDL operations. For example, you can call this operation to add a unique constraint or a unique index, or adjust the unique constraint or the unique index. You can also adjust the unique constraint or fields that compose the unique index. Duplicate data already exists in the unique constraint or unique index that is adjusted or added to the data table. Confirm the rationality of the unique constraint or unique index. If it is reasonable, duplicate data needs to be cleared first, and then the failed task can be re-run.
Use the structure design feature to perform DDL operations that do not involve unique constraints or unique indexes to compose field adjustments. This problem may occur in scenarios where the online DDL mechanism of MySQL provides highly concurrent access to destination table.
  • RDS instance:
    • You can wait for the RDS instance to change during the off-peak period of your business.
    • Contact the corresponding DBA for handling. For more information about how to view the DBA information, see how to view the database corresponding DBA in the DMS console.
  • Non-RDS instance:
    You can use the lock-free data change feature to make changes. For more information, see lock-free data change.

note: The conflict calculation rule for unique indexes includes the length within the index definition, that is, if a field is defined as "name varchar(255)" and the unique index defined on the field is prefixed with "uk(name(5))", then "name='abcdef .......... '" exists on the table. After "name='abcdef'" is written, data writing fails because the first five characters are the same.

Application scope

  • Data Management (DMS)
  • ApsaraDB RDS
    note: This topic applies to apsaradb RDS for MySQL instances or user-created MySQL databases (user-created databases in ECS instances or user-created databases in on-premises data centers).