Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

copr: fix lockerr when streaming #31934

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 1 addition & 20 deletions store/copr/coprocessor.go
Original file line number Diff line number Diff line change
Expand Up @@ -966,7 +966,7 @@ func (worker *copIteratorWorker) handleCopResponse(bo *Backoffer, rpcCtx *tikv.R
}
}
if worker.req.Streaming {
task.ranges = worker.calculateRetry(task.ranges, lastRange, worker.req.Desc)
task.ranges = worker.calculateRemain(task.ranges, lastRange, worker.req.Desc)
}
return []*copTask{task}, nil
}
Expand Down Expand Up @@ -1110,25 +1110,6 @@ func (worker *copIteratorWorker) handleTiDBSendReqErr(err error, task *copTask,
return nil
}

// calculateRetry splits the input ranges into two, and take one of them according to desc flag.
// It's used in streaming API, to calculate which range is consumed and what needs to be retry.
// For example:
// ranges: [r1 --> r2) [r3 --> r4)
// split: [s1 --> s2)
// In normal scan order, all data before s1 is consumed, so the retry ranges should be [s1 --> r2) [r3 --> r4)
// In reverse scan order, all data after s2 is consumed, so the retry ranges should be [r1 --> r2) [r3 --> s2)
func (worker *copIteratorWorker) calculateRetry(ranges *KeyRanges, split *coprocessor.KeyRange, desc bool) *KeyRanges {
if split == nil {
return ranges
}
if desc {
left, _ := ranges.Split(split.End)
return left
}
_, right := ranges.Split(split.Start)
return right
}

// calculateRemain calculates the remain ranges to be processed, it's used in streaming and paging API.
// For example:
// ranges: [r1 --> r2) [r3 --> r4)
Expand Down