Skip to content

Commit 2e43718

Browse files
committed
Add --test-on-replica-skip-replica-stop flag
1 parent a62f9e0 commit 2e43718

File tree

3 files changed

+16
-38
lines changed

3 files changed

+16
-38
lines changed

go/base/context.go

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

85-
Noop bool
86-
TestOnReplica bool
87-
MigrateOnReplica bool
88-
ManualReplicationControl bool
89-
OkToDropTable bool
90-
InitiallyDropOldTable bool
91-
InitiallyDropGhostTable bool
92-
CutOverType CutOver
85+
Noop bool
86+
TestOnReplica bool
87+
MigrateOnReplica bool
88+
TestOnReplicaSkipReplicaStop bool
89+
OkToDropTable bool
90+
InitiallyDropOldTable bool
91+
InitiallyDropGhostTable bool
92+
CutOverType CutOver
9393

9494
TableEngine string
9595
RowsEstimate int64

go/cmd/gh-ost/main.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ func main() {
6060
flag.BoolVar(&migrationContext.SkipRenamedColumns, "skip-renamed-columns", false, "in case your `ALTER` statement renames columns, gh-ost will note that and offer its interpretation of the rename. By default gh-ost does not proceed to execute. This flag tells gh-ost to skip the renamed columns, i.e. to treat what gh-ost thinks are renamed columns as unrelated columns. NOTE: you may lose column data")
6161

6262
executeFlag := flag.Bool("execute", false, "actually execute the alter & migrate the table. Default is noop: do some tests and exit")
63-
testOnReplicaWithManualReplicationControl := flag.Bool("test-on-replica-manual-replication-control", false, "Same as --test-on-replica, but waits for replication to be stopped, instead of stopping it automatically. (Useful in RDS.)")
6463
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)")
6565
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)")
6666

6767
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?")
@@ -150,13 +150,13 @@ func main() {
150150
if migrationContext.SwitchToRowBinlogFormat && migrationContext.AssumeRBR {
151151
log.Fatalf("--switch-to-rbr and --assume-rbr are mutually exclusive")
152152
}
153-
if *testOnReplicaWithManualReplicationControl {
154-
if migrationContext.TestOnReplica {
155-
log.Fatalf("--test-on-replica-manual-replication-control and --test-on-replica are mutually exclusive")
153+
if migrationContext.TestOnReplicaSkipReplicaStop {
154+
if !migrationContext.TestOnReplica {
155+
log.Fatalf("--test-on-replica-skip-replica-stop requires --test-on-replica to be enabled")
156156
}
157-
migrationContext.TestOnReplica = true
158-
migrationContext.ManualReplicationControl = true
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.")
159158
}
159+
160160
switch *cutOver {
161161
case "atomic", "default", "":
162162
migrationContext.CutOverType = base.CutOverAtomic

go/logic/applier.go

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -566,32 +566,10 @@ func (this *Applier) StartSlaveSQLThread() error {
566566
return nil
567567
}
568568

569-
func (this *Applier) isReplicationStopped() bool {
570-
query := `show slave status`
571-
replicationStopped := false
572-
573-
err := sqlutils.QueryRowsMap(this.db, query, func(rowMap sqlutils.RowMap) error {
574-
replicationStopped = rowMap["Slave_IO_Running"].String == "No" && rowMap["Slave_SQL_Running"].String == "No"
575-
return nil
576-
})
577-
578-
if err != nil {
579-
return false
580-
}
581-
return replicationStopped
582-
}
583-
584569
// StopReplication is used by `--test-on-replica` and stops replication.
585570
func (this *Applier) StopReplication() error {
586-
if this.migrationContext.ManualReplicationControl {
587-
for {
588-
log.Info("Waiting for replication to stop...")
589-
if this.isReplicationStopped() {
590-
log.Info("Replication stopped.")
591-
break
592-
}
593-
time.Sleep(5 * time.Second)
594-
}
571+
if this.migrationContext.TestOnReplicaSkipReplicaStop {
572+
log.Warningf("--test-on-replica-skip-replica-stop enabled, we are not stopping replication.")
595573
} else {
596574
if err := this.StopSlaveIOThread(); err != nil {
597575
return err

0 commit comments

Comments
 (0)