File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1087,24 +1087,30 @@ func (this *Migrator) iterateChunks() error {
10871087 log .Debugf ("No rows found in table. Rowcopy will be implicitly empty" )
10881088 return terminateRowIteration (nil )
10891089 }
1090+
1091+ var hasNoFurtherRangeFlag int64
10901092 // Iterate per chunk:
10911093 for {
1092- if atomic .LoadInt64 (& this .rowCopyCompleteFlag ) == 1 {
1094+ if atomic .LoadInt64 (& this .rowCopyCompleteFlag ) == 1 || atomic . LoadInt64 ( & hasNoFurtherRangeFlag ) == 1 {
10931095 // Done
10941096 // There's another such check down the line
10951097 return nil
10961098 }
10971099 copyRowsFunc := func () error {
1098- if atomic .LoadInt64 (& this .rowCopyCompleteFlag ) == 1 {
1100+ if atomic .LoadInt64 (& this .rowCopyCompleteFlag ) == 1 || atomic . LoadInt64 ( & hasNoFurtherRangeFlag ) == 1 {
10991101 // Done.
11001102 // There's another such check down the line
11011103 return nil
11021104 }
1105+
1106+ // When hasFurtherRange is false, original table might be write locked and CalculateNextIterationRangeEndValues would hangs forever
1107+
11031108 hasFurtherRange , err := this .applier .CalculateNextIterationRangeEndValues ()
11041109 if err != nil {
11051110 return terminateRowIteration (err )
11061111 }
11071112 if ! hasFurtherRange {
1113+ atomic .StoreInt64 (& hasNoFurtherRangeFlag , 1 )
11081114 return terminateRowIteration (nil )
11091115 }
11101116 // Copy task:
You can’t perform that action at this time.
0 commit comments