Skip to content

Commit

Permalink
store/copr: use non-buffered channel for coprocessor response (#35988)
Browse files Browse the repository at this point in the history
close #35987
  • Loading branch information
tiancaiamao authored Jul 15, 2022
1 parent 850c869 commit ea306fc
Showing 1 changed file with 1 addition and 15 deletions.
16 changes: 1 addition & 15 deletions store/copr/coprocessor.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,21 +123,7 @@ func (c *CopClient) Send(ctx context.Context, req *kv.Request, variables interfa
it.sendRate = util.NewRateLimit(2 * it.concurrency)
it.respChan = nil
} else {
capacity := it.concurrency
if enabledRateLimitAction {
// The count of cached response in memory is controlled by the capacity of the it.sendRate, not capacity of the respChan.
// As the worker will send finCopResponse after each task being handled, we make the capacity of the respCh equals to
// 2*it.concurrency to avoid deadlock in the unit test caused by the `MustExec` or `Exec`
capacity = it.concurrency * 2
}
// in paging request, a request will be returned in multi batches,
// enlarge the channel size to avoid the request blocked by buffer full.
if req.Paging {
if capacity < 2048 {
capacity = 2048
}
}
it.respChan = make(chan *copResponse, capacity)
it.respChan = make(chan *copResponse)
it.sendRate = util.NewRateLimit(it.concurrency)
}
it.actionOnExceed = newRateLimitAction(uint(it.sendRate.GetCapacity()))
Expand Down

0 comments on commit ea306fc

Please sign in to comment.