Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dm: load table structure from dump files #3295

Merged
merged 9 commits into from
Nov 8, 2021
1 change: 0 additions & 1 deletion dm/loader/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,6 @@ func cleanDumpFiles(cfg *config.SubTaskConfig) {
var lastErr error
for f := range files {
if strings.HasSuffix(f, ".sql") {
// TODO: table structure files are not used now, but we plan to used them in future so not delete them
if strings.HasSuffix(f, "-schema-create.sql") || strings.HasSuffix(f, "-schema.sql") {
continue
}
Expand Down
7 changes: 5 additions & 2 deletions dm/syncer/syncer.go
Original file line number Diff line number Diff line change
Expand Up @@ -1342,7 +1342,11 @@ func (s *Syncer) Run(ctx context.Context) (err error) {
if s.cfg.Mode == config.ModeAll && fresh {
delLoadTask = true
flushCheckpoint = true
// TODO: loadTableStructureFromDump in future
err = s.loadTableStructureFromDump(ctx)
if err != nil {
tctx.L().Warn("error happened when load table structure from dump files", zap.Error(err))
cleanDumpFile = false
}
} else {
cleanDumpFile = false
}
Expand Down Expand Up @@ -2783,7 +2787,6 @@ func (s *Syncer) genRouter() error {
return nil
}

//nolint:unused
func (s *Syncer) loadTableStructureFromDump(ctx context.Context) error {
logger := s.tctx.L()

Expand Down
11 changes: 1 addition & 10 deletions dm/tests/downstream_more_column/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,8 @@ function run() {
run_sql_tidb_with_retry "select count(1) from ${db}.${tb} where c1<100;" "count(1): 2"

run_sql_file $cur/data/db1.increment.sql $MYSQL_HOST1 $MYSQL_PORT1 $MYSQL_PASSWORD1
run_dm_ctl_with_retry $WORK_DIR "127.0.0.1:$MASTER_PORT" \
"query-status test" \
"sourceTable: \`${db1}\`.\`${tb1}\`" 1 \
"targetTable: \`${db}\`.\`${tb}\`" 1 \
"Column count doesn't match value count" 1
run_dm_ctl $WORK_DIR "127.0.0.1:$MASTER_PORT" \
"operate-schema set -s mysql-replica-01 test -d ${db1} -t ${tb1} $cur/data/schema.sql" \
"\"result\": true" 2
# we load table structure from dump files, so there's no error now

run_dm_ctl $WORK_DIR "127.0.0.1:$MASTER_PORT" \
"resume-task test"
# check incremental data
run_sql_tidb_with_retry "select count(1) from ${db}.${tb} where c1>100 and c1<1000;" "count(1): 2"

Expand Down