Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 17 additions & 8 deletions filter-binlog-event.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ filters:
schema-pattern: "test_*"
table-pattern: "t_*"
events: ["truncate table", "drop table"]
sql-pattern: ["^DROP\\s+PROCEDURE", "^CREATE\\s+PROCEDURE"]
action: Ignore
```

Expand Down Expand Up @@ -97,20 +96,30 @@ filters:
action: Do
```

### 过滤 TiDB 不支持的 SQL 语句
### 处理 TiDB 不支持或 DM 无法解析的 SQL 语句

对于 `CREATE PROCEDURE`、`DROP PROCEDURE` 和 `ALTER PROCEDURE`,无需配置过滤规则。DM 会自动跳过这些语句。

在 MySQL 中添加或删除分区时,DM 通常会将变更同步到 TiDB。对于 DM 和 TiDB 都支持的分区操作,无需配置过滤规则。要查看 TiDB 支持分区类型的操作,请参阅[分区管理](/partitioned-table.md#分区管理)。

如果 DM 在处理使用 `ADD PARTITION` 或 `DROP PARTITION` 的 `ALTER TABLE` 语句时报解析错误,并且你不需要将该分区变更同步到 TiDB,则可以使用如下规则跳过该语句。DM 的解析错误并不一定意味着 TiDB 不支持该操作。

当 DM 无法解析某条语句时,它无法应用仅针对特定 schema 或 table 的过滤规则。此时,你需要使用 `schema-pattern: "*"` 且不设置 `table-pattern` 的全局过滤规则。该规则会对迁移任务中所有表的匹配语句生效。

> **警告:**
>
> 为避免过滤掉需要迁移的数据,请尽可能严格地配置该全局过滤规则。
>
> 以下正则表达式匹配 SQL 文本,包括字符串字面量,因此可能误过滤其他 DDL 语句。例如,如果 `ALTER TABLE ... ADD COLUMN` 语句的默认值中包含 `ADD PARTITION`,该语句也可能被跳过。使用此规则前,请确认这些正则表达式不会匹配任何需要同步的 DDL 语句。

```
filters:
filter-procedure-rule:
filter-partition-rule:
schema-pattern: "*"
sql-pattern: [".*\\s+DROP\\s+PROCEDURE", ".*\\s+CREATE\\s+PROCEDURE", "ALTER\\s+TABLE[\\s\\S]*ADD\\s+PARTITION", "ALTER\\s+TABLE[\\s\\S]*DROP\\s+PARTITION"]
sql-pattern: ["ALTER\\s+TABLE[\\s\\S]*ADD\\s+PARTITION", "ALTER\\s+TABLE[\\s\\S]*DROP\\s+PARTITION"]
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
action: Ignore
```

> **注意:**
>
> 全局过滤规则的设置必须尽可能严格,以避免过滤掉需要迁移的数据。

## 探索更多

- [如何通过 SQL 表达式过滤 binlog](/filter-dml-event.md)
4 changes: 2 additions & 2 deletions migrate-small-mysql-shards-to-tidb.md
Original file line number Diff line number Diff line change
Expand Up @@ -153,12 +153,12 @@ routes:
# source-regexp: "(.*)"
# target-column: "c_source"

# 过滤部分 DDL 事件
# 过滤部分不兼容的 DDL 事件
filters:
sale-filter-rule:
schema-pattern: "store_*"
table-pattern: "sale_*"
events: ["truncate table", "drop table", "delete"]
events: ["truncate table", "drop table"]
action: Ignore
store-filter-rule:
schema-pattern: "store_*"
Expand Down
2 changes: 1 addition & 1 deletion migrate-with-more-columns-downstream.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ CREATE TABLE `messages` (
{{< copyable "shell-regular" >}}

```
tiup dmctl --master-addr 172.16.10.71:8261 binlog-schema update -s mysql-01 task-test -d log -t message log.message.sql
tiup dmctl --master-addr 172.16.10.71:8261 binlog-schema update -s mysql-01 task-test log messages log.messages.sql
```

3. 使用 `resume-task` 命令恢复处于 Paused 状态的同步任务。
Expand Down
Loading