From 0a0a21cf07e7b4f43b884e99f3665a3746dcb5f3 Mon Sep 17 00:00:00 2001 From: Frank945946 <108602632+Frank945946@users.noreply.github.com> Date: Tue, 9 Jan 2024 11:03:24 +0800 Subject: [PATCH] dm: add a note about DM to `sql_require_primary_key` (#15993) --- dm/task-configuration-file-full.md | 1 + system-variables.md | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/dm/task-configuration-file-full.md b/dm/task-configuration-file-full.md index c1d81955a3467..95ff752a0b27a 100644 --- a/dm/task-configuration-file-full.md +++ b/dm/task-configuration-file-full.md @@ -45,6 +45,7 @@ target-database: # Configuration of the downstream database insta sql_mode: "ANSI_QUOTES,NO_ZERO_IN_DATE,NO_ZERO_DATE" # Since DM v2.0.0, if this item does not appear in the configuration file, DM automatically fetches a proper value for "sql_mode" from the downstream TiDB. Manual configuration of this item has a higher priority. tidb_skip_utf8_check: 1 # Since DM v2.0.0, if this item does not appear in the configuration file, DM automatically fetches a proper value for "tidb_skip_utf8_check" from the downstream TiDB. Manual configuration of this item has a higher priority. tidb_constraint_check_in_place: 0 + sql_require_primary_key: OFF # Controls whether a table must have a primary key at the session level. During the creation of a DM task, several metadata tables are created in TiDB, and some of them have no primary key. If this parameter is enabled, these metadata tables without primary keys cannot be created, which will cause DM to fail to create the task. In this case, you need to set this parameter to `OFF`. security: # The TLS configuration of the downstream TiDB ssl-ca: "/path/to/ca.pem" ssl-cert: "/path/to/cert.pem" diff --git a/system-variables.md b/system-variables.md index c53d7c8ae4595..7e33c462500e2 100644 --- a/system-variables.md +++ b/system-variables.md @@ -922,6 +922,12 @@ mysql> SHOW GLOBAL VARIABLES LIKE 'max_prepared_stmt_count'; - This feature is based on the similarly named [`sql_require_primary_key`](https://dev.mysql.com/doc/refman/8.0/en/server-system-variables.html#sysvar_sql_require_primary_key) in MySQL 8.0. - It is strongly recommended to enable this variable when using TiCDC. This is because replicating changes to a MySQL sink requires that tables have a primary key. + + +- If you enable this variable and are using TiDB Data Migration (DM) to migrate data, it is recommended that you add `sql_require_ primary_key` to the `session` part in the [DM Task Configuration File](/dm/task-configuration-file-full.md#task-configuration-file-template-advanced) and set it to `OFF`. Otherwise, it will cause DM to fail to create tasks. + + + ### sql_select_limit New in v4.0.2 - Scope: SESSION | GLOBAL