Skip to content

Commit 9d4f30d

Browse files
authored
store: key ranges should be sorted in batch cop retry (pingcap#44623) (pingcap#44632)
close pingcap#44622
1 parent 03c7688 commit 9d4f30d

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

store/copr/batch_coprocessor.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -771,6 +771,10 @@ func (b *batchCopIterator) retryBatchCopTask(ctx context.Context, bo *backoff.Ba
771771
ranges = append(ranges, *ran)
772772
})
773773
}
774+
// need to make sure the key ranges is sorted
775+
sort.Slice(ranges, func(i, j int) bool {
776+
return bytes.Compare(ranges[i].StartKey, ranges[j].StartKey) < 0
777+
})
774778
return buildBatchCopTasks(bo, b.store, NewKeyRanges(ranges), b.req.StoreType, nil, 0, false, 0)
775779
}
776780

0 commit comments

Comments
 (0)