set the request source at the last section (#960)

Signed-off-by: you06 <you1474600@gmail.com>
This commit is contained in:
you06 2023-09-07 21:23:09 +08:00 committed by GitHub
parent 5dd12b06bc
commit 89493ff985
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 4 deletions

View File

@ -2337,9 +2337,10 @@ func (s *replicaSelector) replicaType(rpcCtx *RPCContext) string {
func (s *replicaSelector) patchRequestSource(req *tikvrpc.Request, rpcCtx *RPCContext) {
var sb strings.Builder
sb.WriteString(req.InputRequestSource)
sb.WriteByte('-')
defer func() {
// TiKV does the limit control by the last part of the request source.
sb.WriteByte('_')
sb.WriteString(req.InputRequestSource)
req.RequestSource = sb.String()
}()

View File

@ -1515,7 +1515,7 @@ func (s *testRegionRequestToThreeStoresSuite) TestRetryRequestSource() {
rpcCtx, err := replicaSelector.buildRPCContext(bo)
s.Nil(err)
replicaSelector.patchRequestSource(req, rpcCtx)
s.Equal("test-"+firstReplica, req.RequestSource)
s.Equal(firstReplica+"_test", req.RequestSource)
// retry
setReadType(req, retryReplica)
@ -1526,7 +1526,7 @@ func (s *testRegionRequestToThreeStoresSuite) TestRetryRequestSource() {
s.Nil(err)
req.IsRetryRequest = true
replicaSelector.patchRequestSource(req, rpcCtx)
s.Equal("test-retry_"+firstReplica+"_"+retryReplica, req.RequestSource)
s.Equal("retry_"+firstReplica+"_"+retryReplica+"_test", req.RequestSource)
}
}
}