Skip to content

Commit

Permalink
fix copyRowsFunc hangs bug
Browse files Browse the repository at this point in the history
  • Loading branch information
wangfei committed Jul 23, 2018
1 parent d2726c7 commit 2b78c3c
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion go/logic/migrator.go
Original file line number Diff line number Diff line change
Expand Up @@ -1087,6 +1087,8 @@ func (this *Migrator) iterateChunks() error {
log.Debugf("No rows found in table. Rowcopy will be implicitly empty")
return terminateRowIteration(nil)
}

hasFurtherRange := true
// Iterate per chunk:
for {
if atomic.LoadInt64(&this.rowCopyCompleteFlag) == 1 {
Expand All @@ -1100,7 +1102,10 @@ func (this *Migrator) iterateChunks() error {
// There's another such check down the line
return nil
}
hasFurtherRange, err := this.applier.CalculateNextIterationRangeEndValues()

// When hasFurtherRange is false, original table might be write locked and CalculateNextIterationRangeEndValues would hangs forever
var err error
hasFurtherRange, err = this.applier.CalculateNextIterationRangeEndValues()
if err != nil {
return terminateRowIteration(err)
}
Expand Down Expand Up @@ -1135,6 +1140,9 @@ func (this *Migrator) iterateChunks() error {
}
// Enqueue copy operation; to be executed by executeWriteFuncs()
this.copyRowsQueue <- copyRowsFunc
if !hasFurtherRange {
break
}
}
return nil
}
Expand Down

0 comments on commit 2b78c3c

Please sign in to comment.