Skip to content

Commit 2b78c3c

Browse files
author
wangfei
committed
fix copyRowsFunc hangs bug
1 parent d2726c7 commit 2b78c3c

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

go/logic/migrator.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1087,6 +1087,8 @@ 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+
hasFurtherRange := true
10901092
// Iterate per chunk:
10911093
for {
10921094
if atomic.LoadInt64(&this.rowCopyCompleteFlag) == 1 {
@@ -1100,7 +1102,10 @@ func (this *Migrator) iterateChunks() error {
11001102
// There's another such check down the line
11011103
return nil
11021104
}
1103-
hasFurtherRange, err := this.applier.CalculateNextIterationRangeEndValues()
1105+
1106+
// When hasFurtherRange is false, original table might be write locked and CalculateNextIterationRangeEndValues would hangs forever
1107+
var err error
1108+
hasFurtherRange, err = this.applier.CalculateNextIterationRangeEndValues()
11041109
if err != nil {
11051110
return terminateRowIteration(err)
11061111
}
@@ -1135,6 +1140,9 @@ func (this *Migrator) iterateChunks() error {
11351140
}
11361141
// Enqueue copy operation; to be executed by executeWriteFuncs()
11371142
this.copyRowsQueue <- copyRowsFunc
1143+
if !hasFurtherRange {
1144+
break
1145+
}
11381146
}
11391147
return nil
11401148
}

0 commit comments

Comments
 (0)