Skip to content

Commit 4c97218

Browse files
author
Shlomi Noach
committed
Merge branch 'master' into sql-mode-strict
2 parents 8b76d0e + 56fd82a commit 4c97218

File tree

4 files changed

+25
-10
lines changed

4 files changed

+25
-10
lines changed

go/base/context.go

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -83,13 +83,14 @@ type MigrationContext struct {
8383
ServeSocketFile string
8484
ServeTCPPort int64
8585

86-
Noop bool
87-
TestOnReplica bool
88-
MigrateOnReplica bool
89-
OkToDropTable bool
90-
InitiallyDropOldTable bool
91-
InitiallyDropGhostTable bool
92-
CutOverType CutOver
86+
Noop bool
87+
TestOnReplica bool
88+
MigrateOnReplica bool
89+
TestOnReplicaSkipReplicaStop bool
90+
OkToDropTable bool
91+
InitiallyDropOldTable bool
92+
InitiallyDropGhostTable bool
93+
CutOverType CutOver
9394

9495
TableEngine string
9596
RowsEstimate int64

go/cmd/gh-ost/main.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ func main() {
6161

6262
executeFlag := flag.Bool("execute", false, "actually execute the alter & migrate the table. Default is noop: do some tests and exit")
6363
flag.BoolVar(&migrationContext.TestOnReplica, "test-on-replica", false, "Have the migration run on a replica, not on the master. At the end of migration replication is stopped, and tables are swapped and immediately swap-revert. Replication remains stopped and you can compare the two tables for building trust")
64+
flag.BoolVar(&migrationContext.TestOnReplicaSkipReplicaStop, "test-on-replica-skip-replica-stop", false, "When --test-on-replica is enabled, do not issue commands stop replication (requires --test-on-replica)")
6465
flag.BoolVar(&migrationContext.MigrateOnReplica, "migrate-on-replica", false, "Have the migration run on a replica, not on the master. This will do the full migration on the replica including cut-over (as opposed to --test-on-replica)")
6566

6667
flag.BoolVar(&migrationContext.OkToDropTable, "ok-to-drop-table", false, "Shall the tool drop the old table at end of operation. DROPping tables can be a long locking operation, which is why I'm not doing it by default. I'm an online tool, yes?")
@@ -149,6 +150,13 @@ func main() {
149150
if migrationContext.SwitchToRowBinlogFormat && migrationContext.AssumeRBR {
150151
log.Fatalf("--switch-to-rbr and --assume-rbr are mutually exclusive")
151152
}
153+
if migrationContext.TestOnReplicaSkipReplicaStop {
154+
if !migrationContext.TestOnReplica {
155+
log.Fatalf("--test-on-replica-skip-replica-stop requires --test-on-replica to be enabled")
156+
}
157+
log.Warning("--test-on-replica-skip-replica-stop enabled. We will not stop replication before cut-over. Ensure you have a plugin that does this.")
158+
}
159+
152160
switch *cutOver {
153161
case "atomic", "default", "":
154162
migrationContext.CutOverType = base.CutOverAtomic

go/logic/applier.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -574,6 +574,7 @@ func (this *Applier) StopReplication() error {
574574
if err := this.StopSlaveSQLThread(); err != nil {
575575
return err
576576
}
577+
577578
readBinlogCoordinates, executeBinlogCoordinates, err := mysql.GetReplicationBinlogCoordinates(this.db)
578579
if err != nil {
579580
return err

go/logic/migrator.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -478,9 +478,14 @@ func (this *Migrator) cutOver() (err error) {
478478
// the same cut-over phase as the master would use. That means we take locks
479479
// and swap the tables.
480480
// The difference is that we will later swap the tables back.
481-
log.Debugf("testing on replica. Stopping replication IO thread")
482-
if err := this.retryOperation(this.applier.StopReplication); err != nil {
483-
return err
481+
482+
if this.migrationContext.TestOnReplicaSkipReplicaStop {
483+
log.Warningf("--test-on-replica-skip-replica-stop enabled, we are not stopping replication.")
484+
} else {
485+
log.Debugf("testing on replica. Stopping replication IO thread")
486+
if err := this.retryOperation(this.applier.StopReplication); err != nil {
487+
return err
488+
}
484489
}
485490
// We're merly testing, we don't want to keep this state. Rollback the renames as possible
486491
defer this.applier.RenameTablesRollback()

0 commit comments

Comments
 (0)