From 3f3a10a2133ae7318536f260bcdbd42ad700e2b0 Mon Sep 17 00:00:00 2001 From: Morgan Tocker Date: Mon, 14 Nov 2022 14:47:00 -0700 Subject: [PATCH] Address PR feedback --- go/logic/applier_test.go | 1 - go/logic/migrator.go | 23 +++++++++-------------- 2 files changed, 9 insertions(+), 15 deletions(-) diff --git a/go/logic/applier_test.go b/go/logic/applier_test.go index 44d1fc7..a356351 100644 --- a/go/logic/applier_test.go +++ b/go/logic/applier_test.go @@ -182,5 +182,4 @@ func TestApplierInstantDDL(t *testing.T) { stmt := applier.generateInstantDDLQuery() test.S(t).ExpectEquals(stmt, "ALTER /* gh-ost */ TABLE `test`.`mytable` ADD INDEX (foo), ALGORITHM=INSTANT") }) - } diff --git a/go/logic/migrator.go b/go/logic/migrator.go index 0dcf53f..31e21cc 100644 --- a/go/logic/migrator.go +++ b/go/logic/migrator.go @@ -351,6 +351,15 @@ func (this *Migrator) Migrate() (err error) { if err := this.initiateInspector(); err != nil { return err } + if err := this.initiateStreaming(); err != nil { + return err + } + if err := this.initiateApplier(); err != nil { + return err + } + if err := this.createFlagFiles(); err != nil { + return err + } // In MySQL 8.0 (and possibly earlier) some DDL statements can be applied instantly. // Attempt to do this if AttemptInstantDDL is set. if this.migrationContext.AttemptInstantDDL { @@ -363,16 +372,6 @@ func (this *Migrator) Migrate() (err error) { } } - if err := this.initiateStreaming(); err != nil { - return err - } - if err := this.initiateApplier(); err != nil { - return err - } - if err := this.createFlagFiles(); err != nil { - return err - } - initialLag, _ := this.inspector.getReplicationLag() this.migrationContext.Log.Infof("Waiting for ghost table to be migrated. Current lag is %+v", initialLag) <-this.ghostTableMigrated @@ -750,10 +749,6 @@ func (this *Migrator) initiateServer() (err error) { // using a ALGORITHM=INSTANT assertion. If this fails, it will return an error, // in which case the original algorithm should be used. func (this *Migrator) attemptInstantDDL() (err error) { - this.applier = NewApplier(this.migrationContext) - if err := this.applier.InitDBConnections(); err != nil { - return err - } return this.applier.AttemptInstantDDL() }