gravity icon indicating copy to clipboard operation
gravity copied to clipboard

MySQL2TiDB better support gh-ost

Open Ryan-Git opened this issue 6 years ago • 2 comments

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?

Ryan-Git avatar Nov 21 '19 08:11 Ryan-Git

----------------------------------------伪装成从库------------------------------------- 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

xialuo1990 avatar Nov 21 '19 08:11 xialuo1990

So we need to

  • ignore create table stmt if table name begins with _ and ends with _ghc or _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 with gho, generate alter table stmt comparing gho and origin table schema

Ryan-Git avatar Nov 21 '19 08:11 Ryan-Git