Address PR feedback

This commit is contained in:
Morgan Tocker 2022-11-14 14:47:00 -07:00
parent cfd83728ed
commit 3f3a10a213
2 changed files with 9 additions and 15 deletions

View File

@ -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")
})
}

View File

@ -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()
}