Skip to content
This repository has been archived by the owner on Nov 24, 2023. It is now read-only.

Commit

Permalink
syncer: support two online-ddl pt and gh-ost on one task (#1904)
Browse files Browse the repository at this point in the history
  • Loading branch information
okJiang authored Jul 26, 2021
1 parent 5c5e1f3 commit 4bea97f
Show file tree
Hide file tree
Showing 33 changed files with 435 additions and 551 deletions.
6 changes: 4 additions & 2 deletions dm/config/subtask.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,10 @@ type SubTaskConfig struct {
flagSet *flag.FlagSet

// when in sharding, multi dm-workers do one task
IsSharding bool `toml:"is-sharding" json:"is-sharding"`
ShardMode string `toml:"shard-mode" json:"shard-mode"`
IsSharding bool `toml:"is-sharding" json:"is-sharding"`
ShardMode string `toml:"shard-mode" json:"shard-mode"`
OnlineDDL bool `toml:"online-ddl" json:"online-ddl"`
// deprecated
OnlineDDLScheme string `toml:"online-ddl-scheme" json:"online-ddl-scheme"`

// handle schema/table name mode, and only for schema/table name/pattern
Expand Down
16 changes: 8 additions & 8 deletions dm/config/subtask_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ import (

func (t *testConfig) TestSubTask(c *C) {
cfg := &SubTaskConfig{
Name: "test-task",
IsSharding: true,
ShardMode: "optimistic",
SourceID: "mysql-instance-01",
OnlineDDLScheme: "pt",
Name: "test-task",
IsSharding: true,
ShardMode: "optimistic",
SourceID: "mysql-instance-01",
OnlineDDL: true,
From: DBConfig{
Host: "127.0.0.1",
Port: 3306,
Expand Down Expand Up @@ -70,9 +70,9 @@ func (t *testConfig) TestSubTask(c *C) {
func (t *testConfig) TestSubTaskAdjustFail(c *C) {
newSubTaskConfig := func() *SubTaskConfig {
return &SubTaskConfig{
Name: "test-task",
SourceID: "mysql-instance-01",
OnlineDDLScheme: "pt",
Name: "test-task",
SourceID: "mysql-instance-01",
OnlineDDL: true,
From: DBConfig{
Host: "127.0.0.1",
Port: 3306,
Expand Down
8 changes: 7 additions & 1 deletion dm/config/task.go
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,8 @@ type TaskConfig struct {

MySQLInstances []*MySQLInstance `yaml:"mysql-instances" toml:"mysql-instances" json:"mysql-instances"`

OnlineDDL bool `yaml:"online-ddl" toml:"online-ddl" json:"online-ddl"`
// deprecated
OnlineDDLScheme string `yaml:"online-ddl-scheme" toml:"online-ddl-scheme" json:"online-ddl-scheme"`

Routes map[string]*router.TableRule `yaml:"routes" toml:"routes" json:"routes"`
Expand Down Expand Up @@ -426,6 +428,9 @@ func (c *TaskConfig) adjust() error {

if c.OnlineDDLScheme != "" && c.OnlineDDLScheme != PT && c.OnlineDDLScheme != GHOST {
return terror.ErrConfigOnlineSchemeNotSupport.Generate(c.OnlineDDLScheme)
} else if c.OnlineDDLScheme == PT || c.OnlineDDLScheme == GHOST {
c.OnlineDDL = true
log.L().Warn("'online-ddl-scheme' will be deprecated soon. Recommend that use online-ddl instead of online-ddl-scheme.")
}

if c.TargetDB == nil {
Expand Down Expand Up @@ -689,7 +694,7 @@ func (c *TaskConfig) SubTaskConfigs(sources map[string]DBConfig) ([]*SubTaskConf
cfg := NewSubTaskConfig()
cfg.IsSharding = c.IsSharding
cfg.ShardMode = c.ShardMode
cfg.OnlineDDLScheme = c.OnlineDDLScheme
cfg.OnlineDDL = c.OnlineDDL
cfg.IgnoreCheckingItems = c.IgnoreCheckingItems
cfg.Name = c.Name
cfg.Mode = c.TaskMode
Expand Down Expand Up @@ -785,6 +790,7 @@ func FromSubTaskConfigs(stCfgs ...*SubTaskConfig) *TaskConfig {
c.HeartbeatReportInterval = stCfg0.HeartbeatReportInterval
c.CaseSensitive = stCfg0.CaseSensitive
c.TargetDB = &stCfg0.To // just ref
c.OnlineDDL = stCfg0.OnlineDDL
c.OnlineDDLScheme = stCfg0.OnlineDDLScheme
c.CleanDumpFile = stCfg0.CleanDumpFile
c.MySQLInstances = make([]*MySQLInstance, 0, len(stCfgs))
Expand Down
10 changes: 5 additions & 5 deletions dm/config/task_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ task-mode: all
shard-mode: "pessimistic"
meta-schema: "dm_meta"
case-sensitive: false
online-ddl-scheme: "gh-ost"
online-ddl: true
clean-dump-file: true
target-database:
Expand Down Expand Up @@ -144,7 +144,7 @@ task-mode: all
shard-mode: "pessimistic"
meta-schema: "dm_meta"
case-sensitive: false
online-ddl-scheme: "gh-ost"
online-ddl: true
clean-dump-file: true
target-database:
Expand Down Expand Up @@ -540,7 +540,7 @@ func WordCount(s string) map[string]int {
func (t *testConfig) TestGenAndFromSubTaskConfigs(c *C) {
var (
shardMode = ShardOptimistic
onlineDDLScheme = "pt"
onlineDDL = true
name = "from-sub-tasks"
taskMode = "incremental"
ignoreCheckingItems = []string{VersionChecking, BinlogRowImageChecking}
Expand Down Expand Up @@ -645,7 +645,7 @@ func (t *testConfig) TestGenAndFromSubTaskConfigs(c *C) {
stCfg1 = &SubTaskConfig{
IsSharding: true,
ShardMode: shardMode,
OnlineDDLScheme: onlineDDLScheme,
OnlineDDL: onlineDDL,
CaseSensitive: true,
Name: name,
Mode: taskMode,
Expand Down Expand Up @@ -770,7 +770,7 @@ func (t *testConfig) TestGenAndFromSubTaskConfigs(c *C) {
ExpressionFilters: []string{"expr-filter-01"},
},
},
OnlineDDLScheme: onlineDDLScheme,
OnlineDDL: onlineDDL,
Routes: map[string]*router.TableRule{
"route-01": &routeRule1,
"route-02": &routeRule2,
Expand Down
3 changes: 1 addition & 2 deletions syncer/ddl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -417,8 +417,7 @@ func (s *testSyncerSuite) TestResolveOnlineDDL(c *C) {
}

for _, ca := range cases {
fn := onlineddl.OnlineDDLSchemes[ca.onlineType]
plugin, err := fn(tctx, s.cfg)
plugin, err := onlineddl.NewRealOnlinePlugin(tctx, s.cfg)
c.Assert(err, IsNil)
syncer := NewSyncer(s.cfg, nil)
syncer.onlineDDL = plugin
Expand Down
6 changes: 0 additions & 6 deletions syncer/online-ddl-tools/base.go

This file was deleted.

184 changes: 0 additions & 184 deletions syncer/online-ddl-tools/ghost.go

This file was deleted.

Loading

0 comments on commit 4bea97f

Please sign in to comment.