pingcap / dm

Data Migration Platform
Apache License 2.0
456 stars 188 forks source link

why dm must save table structure info in cache? #2293

Closed lddlww closed 2 years ago

lddlww commented 2 years ago

Before asking a question, make sure you have

What is your question?

problem: i use dm to sync data from mysql to tidb,and ignore [alter table] event,when alter table in mysql,i modify tidb simultaneously manually;but i foud dm stop sync and throw errors,the reason is table structure does not match in it,then i use operate-schema command to modify dm table structure ,after dm reworks;but this operation is very troublesome for a large number of modifications to the table structure

question: 1、i wanna to know why dm have to cache table structure? 2、how can i do to autosync table structure to dm cache when alter mysql table structure which ignored [alter table] event?

more detail: 1、in mysql i have some tables like follow:

mysql> show tables like 'orders%'
+-----------------------------+
| Tables_in_hunter (orders_%) |
+-----------------------------+
| orders_3001                 |
| orders_3002                 |
| orders_3003                 |
| orders_3004                 |
| orders_3005                 |
| orders_3006                 |
+-----------------------------+
6 rows in set (0.00 sec)

2、create dm task to merge orders_% tables to tidb,task routes like follow:

routes:
    route01:
        schema-pattern: "hter"
        target-schema: "hter"
    route02:
        schema-pattern: "hter"
        table-pattern: "orders_*"
        target-schema: "hter"
        target-table: "orders"

so i have to ignore [alter table] event

lance6716 commented 2 years ago

1 MySQL binlog doesn't have table structure, so DM must maintain the table structure for its purpose like get column names. 2 we have implemented it in newer version (related to https://github.com/pingcap/tiflow/issues/3239, but I can't find the PR because issue transfer).

And this repo has been move to https://github.com/pingcap/tiflow/tree/master/dm , you can watch tiflow

lddlww commented 2 years ago

oh,thanks for reply and remind