Skip to content

Commit 04c0be6

Browse files
author
Shlomi Noach
authored
Merge branch 'master' into ipv6
2 parents 959d1af + 17b170d commit 04c0be6

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

go/logic/migrator.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff 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:

0 commit comments

Comments
 (0)