@@ -85,7 +85,7 @@ type Migrator struct {
8585
8686 handledChangelogStates map [string ]bool
8787
88- finishedMigrating bool
88+ finishedMigrating int64
8989}
9090
9191func NewMigrator (context * base.MigrationContext ) * Migrator {
@@ -100,7 +100,7 @@ func NewMigrator(context *base.MigrationContext) *Migrator {
100100 copyRowsQueue : make (chan tableWriteFunc ),
101101 applyEventsQueue : make (chan * applyEventStruct , base .MaxEventsBatchSize ),
102102 handledChangelogStates : make (map [string ]bool ),
103- finishedMigrating : false ,
103+ finishedMigrating : 0 ,
104104 }
105105 return migrator
106106}
@@ -727,7 +727,7 @@ func (this *Migrator) initiateStatus() error {
727727 this .printStatus (ForcePrintStatusAndHintRule )
728728 statusTick := time .Tick (1 * time .Second )
729729 for range statusTick {
730- if this .finishedMigrating {
730+ if atomic . LoadInt64 ( & this .finishedMigrating ) > 0 {
731731 return nil
732732 }
733733 go this .printStatus (HeuristicPrintStatusRule )
@@ -954,7 +954,7 @@ func (this *Migrator) initiateStreaming() error {
954954 go func () {
955955 ticker := time .Tick (1 * time .Second )
956956 for range ticker {
957- if this .finishedMigrating {
957+ if atomic . LoadInt64 ( & this .finishedMigrating ) > 0 {
958958 return
959959 }
960960 this .migrationContext .SetRecentBinlogCoordinates (* this .eventsStreamer .GetCurrentBinlogCoordinates ())
@@ -1147,7 +1147,7 @@ func (this *Migrator) executeWriteFuncs() error {
11471147 return nil
11481148 }
11491149 for {
1150- if this .finishedMigrating {
1150+ if atomic . LoadInt64 ( & this .finishedMigrating ) > 0 {
11511151 return nil
11521152 }
11531153
@@ -1232,7 +1232,7 @@ func (this *Migrator) finalCleanup() error {
12321232}
12331233
12341234func (this * Migrator ) teardown () {
1235- this .finishedMigrating = true
1235+ atomic . StoreInt64 ( & this .finishedMigrating , 1 )
12361236
12371237 if this .inspector != nil {
12381238 log .Infof ("Tearing down inspector" )
0 commit comments