Skip to content

Commit

Permalink
import: fix dup-detect failure on index data (#39571)
Browse files Browse the repository at this point in the history
close #39476
  • Loading branch information
dsdashun authored Dec 2, 2022
1 parent 4d11314 commit eed9ceb
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions br/pkg/lightning/backend/local/duplicate.go
Original file line number Diff line number Diff line change
Expand Up @@ -553,19 +553,22 @@ func (m *DuplicateManager) buildDupTasks() ([]dupTask, error) {
return nil, errors.Trace(err)
}
tasks := make([]dupTask, 0, keyRanges.TotalRangeNum()*(1+len(m.tbl.Meta().Indices)))
putToTaskFunc := func(ranges []tidbkv.KeyRange) {
putToTaskFunc := func(ranges []tidbkv.KeyRange, indexInfo *model.IndexInfo) {
if len(ranges) == 0 {
return
}
tid := tablecodec.DecodeTableID(ranges[0].StartKey)
for _, r := range ranges {
tasks = append(tasks, dupTask{
KeyRange: r,
tableID: tid,
KeyRange: r,
tableID: tid,
indexInfo: indexInfo,
})
}
}
keyRanges.ForEachPartition(putToTaskFunc)
keyRanges.ForEachPartition(func(ranges []tidbkv.KeyRange) {
putToTaskFunc(ranges, nil)
})
for _, indexInfo := range m.tbl.Meta().Indices {
if indexInfo.State != model.StatePublic {
continue
Expand All @@ -574,7 +577,9 @@ func (m *DuplicateManager) buildDupTasks() ([]dupTask, error) {
if err != nil {
return nil, errors.Trace(err)
}
keyRanges.ForEachPartition(putToTaskFunc)
keyRanges.ForEachPartition(func(ranges []tidbkv.KeyRange) {
putToTaskFunc(ranges, indexInfo)
})
}
return tasks, nil
}
Expand Down

0 comments on commit eed9ceb

Please sign in to comment.