MySQL2TiDB better support gh-ost
TiDB supports online schema change natively while MySQL often leverages tools like gh-ost. For task syncing from MySQL to TiDB, we'd better come up with a solution.
@xialuo1990 could you list ddl stmts gh-ost would execute during schema change?
----------------------------------------伪装成从库-------------------------------------
2018-05-28 03:38:12 INFO Connecting binlog streamer at mysql-bin.000006:1037154042
2018/05/28 03:38:12 binlogsyncer.go:246: [info] begin to sync binlog from position (mysql-bin.000006, 1037154042)
2018/05/28 03:38:12 binlogsyncer.go:139: [info] register slave for master server 10.0.222.222:3302
2018/05/28 03:38:12 binlogsyncer.go:573: [info] rotate to (mysql-bin.000006, 1037154042)
----------------------------------------建立临时表-------------------------------------
2018-05-28 03:38:13 INFO Creating changelog table optimizesql._mbk_interfere_test_ghc
2018-05-28 03:38:13 INFO Changelog table created
2018-05-28 03:38:13 INFO Creating ghost table optimizesql._mbk_interfere_test_gho
2018-05-28 03:38:13 INFO Ghost table created
2018-05-28 03:38:13 INFO Altering ghost table optimizesql._mbk_interfere_test_gho
2018-05-28 03:38:13 INFO Ghost table altered
----------------------------------------拷贝数据---------------------------------------
Copy: 1001/1001 100.0%; Applied: 0; Backlog: 1/1000; Time: 2s(total), 1s(copy); streamer: mysql-bin.000006:1037231288; State: migrating; ETA: duelock2018-05-28
----------------------------------------给原标和临时表加锁-------------------------------
03:38:14 INFO Locking optimizesql.mbk_interfere_test, optimizesql._mbk_interfere_test_del
----------------------------------------确认增量数据拷贝完毕-----------------------------
2018-05-28 03:38:14 INFO Writing changelog state: AllEventsUpToLockProcessed:1527449894246894344
----------------------------------------将临时表变更为原表-----------------------------
2018-05-28 03:38:15 INFO Issuing and expecting this to block: rename /* gh-ost */ table optimizesql.mbk_interfere_test to optimizesql._mbk_interfere_test_del, optimizesql._mbk_interfere_test_gho to optimizesql.mbk_interfere_test
So we need to
- ignore create table stmt if table name begins with
_and ends with_ghcor_gho - ignore alter table stmt if table name begins with
_and ends with_gho - ignore rename table if target name begins with
_and ends with_del - rewrite rename table if source name begins with
_and ends withgho, generate alter table stmt comparing gho and origin table schema