Skip to content

Commit 0fb045d

Browse files
author
Shlomi Noach
authored
Merge pull request #108 from github/cut-over-cleanup
replica-migration cleanup; updating allEventsUpToLockProcessedInjecte…
2 parents f3d78be + 7a70c24 commit 0fb045d

File tree

1 file changed

+4
-16
lines changed

1 file changed

+4
-16
lines changed

go/logic/migrator.go

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -475,6 +475,7 @@ func (this *Migrator) cutOver() (err error) {
475475
}
476476
// We're merly testing, we don't want to keep this state. Rollback the renames as possible
477477
defer this.applier.RenameTablesRollback()
478+
// We further proceed to do the cutover by normal means; the 'defer' above will rollback the swap
478479
}
479480
if this.migrationContext.CutOverType == base.CutOverAtomic {
480481
// Atomic solution: we use low timeout and multiple attempts. But for
@@ -525,6 +526,7 @@ func (this *Migrator) waitForEventsUpToLock() (err error) {
525526
func (this *Migrator) cutOverTwoStep() (err error) {
526527
atomic.StoreInt64(&this.inCutOverCriticalActionFlag, 1)
527528
defer atomic.StoreInt64(&this.inCutOverCriticalActionFlag, 0)
529+
atomic.StoreInt64(&this.allEventsUpToLockProcessedInjectedFlag, 0)
528530

529531
if err := this.retryOperation(this.applier.LockOriginalTable); err != nil {
530532
return err
@@ -555,6 +557,8 @@ func (this *Migrator) atomicCutOver() (err error) {
555557
this.applier.DropAtomicCutOverSentryTableIfExists()
556558
}()
557559

560+
atomic.StoreInt64(&this.allEventsUpToLockProcessedInjectedFlag, 0)
561+
558562
lockOriginalSessionIdChan := make(chan int64, 2)
559563
tableLocked := make(chan error, 2)
560564
okToUnlockTable := make(chan bool, 3)
@@ -633,22 +637,6 @@ func (this *Migrator) atomicCutOver() (err error) {
633637
return nil
634638
}
635639

636-
// stopWritesAndCompleteMigrationOnReplica will stop replication IO thread, apply
637-
// what DML events are left, and that's it.
638-
// This only applies in --test-on-replica. It leaves replication stopped, with both tables
639-
// in sync. There is no table swap.
640-
func (this *Migrator) stopWritesAndCompleteMigrationOnReplica() (err error) {
641-
log.Debugf("testing on replica. Instead of LOCK tables I will STOP SLAVE")
642-
if err := this.retryOperation(this.applier.StopReplication); err != nil {
643-
return err
644-
}
645-
646-
this.waitForEventsUpToLock()
647-
648-
log.Info("Table duplicated with new schema. Am not touching the original table. Replication is stopped. You may now compare the two tables to gain trust into this tool's operation")
649-
return nil
650-
}
651-
652640
// onServerCommand responds to a user's interactive command
653641
func (this *Migrator) onServerCommand(command string, writer *bufio.Writer) (err error) {
654642
defer writer.Flush()

0 commit comments

Comments
 (0)