Skip to content

Commit

Permalink
add comment
Browse files Browse the repository at this point in the history
  • Loading branch information
winoros committed Aug 22, 2018
1 parent 136c85b commit bdb5fda
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions store/tikv/coprocessor.go
Expand Up @@ -236,6 +236,7 @@ func (r *copRanges) split(key []byte) (*copRanges, *copRanges) {
return r.slice(0, n), r.slice(n, r.len())
}

// rangesPerTask limits the length of the ranges slice sent in one copTask.
const rangesPerTask = 25000

func buildCopTasks(bo *Backoffer, cache *RegionCache, ranges *copRanges, desc bool, streaming bool) ([]*copTask, error) {
Expand All @@ -248,6 +249,8 @@ func buildCopTasks(bo *Backoffer, cache *RegionCache, ranges *copRanges, desc bo

var tasks []*copTask
appendTask := func(region RegionVerID, ranges *copRanges) {
// TiKV will return gRPC error if the message is too large. So we need to limit the length of the ranges slice
// to make sure the message can be sent successfully.
rLen := ranges.len()
for i := 0; i < rLen; {
nextI := mathutil.Min(i+rangesPerTask, rLen)
Expand Down

0 comments on commit bdb5fda

Please sign in to comment.