@@ -79,7 +79,7 @@ type Migrator struct {
7979
8080 firstThrottlingCollected chan bool
8181 ghostTableMigrated chan bool
82- rowCopyComplete chan bool
82+ rowCopyComplete chan error
8383 allEventsUpToLockProcessed chan string
8484
8585 rowCopyCompleteFlag int64
@@ -97,7 +97,7 @@ func NewMigrator() *Migrator {
9797 parser : sql .NewParser (),
9898 ghostTableMigrated : make (chan bool ),
9999 firstThrottlingCollected : make (chan bool , 3 ),
100- rowCopyComplete : make (chan bool ),
100+ rowCopyComplete : make (chan error ),
101101 allEventsUpToLockProcessed : make (chan string ),
102102
103103 copyRowsQueue : make (chan tableWriteFunc ),
@@ -180,11 +180,16 @@ func (this *Migrator) executeAndThrottleOnError(operation func() error) (err err
180180// consumeRowCopyComplete blocks on the rowCopyComplete channel once, and then
181181// consumes and drops any further incoming events that may be left hanging.
182182func (this * Migrator ) consumeRowCopyComplete () {
183- <- this .rowCopyComplete
183+ if err := <- this .rowCopyComplete ; err != nil {
184+ this .migrationContext .PanicAbort <- err
185+ }
184186 atomic .StoreInt64 (& this .rowCopyCompleteFlag , 1 )
185187 this .migrationContext .MarkRowCopyEndTime ()
186188 go func () {
187- for <- this .rowCopyComplete {
189+ for err := range this .rowCopyComplete {
190+ if err != nil {
191+ this .migrationContext .PanicAbort <- err
192+ }
188193 }
189194 }()
190195}
@@ -1024,7 +1029,7 @@ func (this *Migrator) initiateApplier() error {
10241029// a chunk of rows onto the ghost table.
10251030func (this * Migrator ) iterateChunks () error {
10261031 terminateRowIteration := func (err error ) error {
1027- this .rowCopyComplete <- true
1032+ this .rowCopyComplete <- err
10281033 return log .Errore (err )
10291034 }
10301035 if this .migrationContext .Noop {
@@ -1076,7 +1081,10 @@ func (this *Migrator) iterateChunks() error {
10761081 atomic .AddInt64 (& this .migrationContext .Iteration , 1 )
10771082 return nil
10781083 }
1079- return this .retryOperation (applyCopyRowsFunc )
1084+ if err := this .retryOperation (applyCopyRowsFunc ); err != nil {
1085+ return terminateRowIteration (err )
1086+ }
1087+ return nil
10801088 }
10811089 // Enqueue copy operation; to be executed by executeWriteFuncs()
10821090 this .copyRowsQueue <- copyRowsFunc
0 commit comments