locate: implement request attempt admission tracking and related statistics - #2026
locate: implement request attempt admission tracking and related statistics#2026solotzg wants to merge 6 commits into
Conversation
…istics Signed-off-by: Zhigao TONG <tongzhigao@pingcap.com>
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
Hi @solotzg. Thanks for your PR. I'm waiting for a tikv member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
|
Welcome @solotzg! |
📝 WalkthroughWalkthroughRequest-attempt admission is added to the RPC request contract and integrated into asynchronous and retry execution. Admission release handling covers successful attempts, errors, cancellation, RPC statistics, and store-limit termination. ChangesRequest Attempt Admission
Estimated code review effort: 4 (Complex) | ~45 minutes Sequence Diagram(s)sequenceDiagram
participant Request
participant SendReqAsync
participant sendReqState
participant RequestAttemptAdmission
participant RPC
Request->>SendReqAsync: submit request
SendReqAsync->>sendReqState: acquire admission for selected store
sendReqState->>RequestAttemptAdmission: admit RPC attempt
RequestAttemptAdmission-->>sendReqState: release function or error
sendReqState->>RPC: send admitted attempt
RPC-->>sendReqState: return attempt result
sendReqState->>RequestAttemptAdmission: release admission
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@internal/locate/region_request.go`:
- Around line 953-971: Update acquireRequestAttemptAdmission to apply
s.args.timeout when invoking req.RequestAttemptAdmission, ensuring admission
cannot outlive the per-attempt RPC deadline. Use the existing request context as
the parent, preserve cancellation/error propagation, and retain the current
wait-time recording and release handling.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: ba93397c-a8aa-4bcf-ba80-616225ab0c5a
📒 Files selected for processing (4)
internal/locate/region_request.gointernal/locate/region_request3_test.gointernal/locate/region_request_test.gotikvrpc/tikvrpc.go
…ated stats handling Signed-off-by: Zhigao TONG <tongzhigao@pingcap.com>
Signed-off-by: Zhigao TONG <tongzhigao@pingcap.com>
|
/cc @windtalker |
|
@solotzg: GitHub didn't allow me to request PR reviews from the following users: windtalker. Note that only tikv members and repo collaborators can review this PR, and authors cannot review their own PRs. DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
…n documentation Signed-off-by: Zhigao TONG <tongzhigao@pingcap.com>
|
/cc @windtalker @cfzjywxk |
|
@solotzg: GitHub didn't allow me to request PR reviews from the following users: windtalker. Note that only tikv members and repo collaborators can review this PR, and authors cannot review their own PRs. DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
Problem
Issue Number: close #2035
TiDB needs to limit concurrent coprocessor requests per query and per TiKV
store. The target store is selected inside client-go and may change during
region retries, so acquiring admission before calling client-go cannot
accurately limit the actual target store.
The admission token should cover exactly one RPC attempt and must be released
before another attempt is admitted.
What changed
tikvrpc.RequestAttemptAdmissionFuncandRequest.RequestAttemptAdmission.RPC attempt, including retries.
returns both a release function and an error.
SendReqAsync.the per-attempt RPC timeout starts after admission succeeds.
When the callback is nil, existing request behavior is unchanged.
Error and cancellation semantics
canceled.
Tests
Added coverage for:
Tests run:
go test ./internal/locate -run 'TestRegionRequestToSingleStore/TestRequestAttemptAdmission|TestRegionRequestToThreeStores/TestRequestAttemptAdmissionUsesRetryStore' -count=10go test -race ./internal/locate -run 'TestRegionRequestToSingleStore/TestRequestAttemptAdmission|TestRegionRequestToThreeStores/TestRequestAttemptAdmissionUsesRetryStore' -count=1Compatibility
This is an additive client API. Existing callers are unaffected unless they set
RequestAttemptAdmission.The associated TiDB change installs the callback only for TiKV coprocessor
requests.
Related