Skip to content

Commit

Permalink
store: key ranges should be sorted in batch cop retry (#44623)
Browse files Browse the repository at this point in the history
close #44622
  • Loading branch information
windtalker authored Jun 13, 2023
1 parent bb68e2e commit d934ef8
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions store/copr/batch_coprocessor.go
Original file line number Diff line number Diff line change
Expand Up @@ -1099,6 +1099,10 @@ func (b *batchCopIterator) retryBatchCopTask(ctx context.Context, bo *backoff.Ba
ranges = append(ranges, *ran)
})
}
// need to make sure the key ranges is sorted
slices.SortFunc(ranges, func(i, j kv.KeyRange) bool {
return bytes.Compare(i.StartKey, j.StartKey) < 0
})
ret, err := buildBatchCopTasksForNonPartitionedTable(ctx, bo, b.store, NewKeyRanges(ranges), b.req.StoreType, false, 0, false, 0, tiflashcompute.DispatchPolicyInvalid)
return ret, err
}
Expand All @@ -1116,6 +1120,10 @@ func (b *batchCopIterator) retryBatchCopTask(ctx context.Context, bo *backoff.Ba
})
}
}
// need to make sure the key ranges is sorted
slices.SortFunc(ranges, func(i, j kv.KeyRange) bool {
return bytes.Compare(i.StartKey, j.StartKey) < 0
})
keyRanges = append(keyRanges, NewKeyRanges(ranges))
}
ret, err := buildBatchCopTasksForPartitionedTable(ctx, bo, b.store, keyRanges, b.req.StoreType, false, 0, false, 0, pid, tiflashcompute.DispatchPolicyInvalid)
Expand Down

0 comments on commit d934ef8

Please sign in to comment.