Skip to content

gc: make GC state reads respect request cancellation - #11136

Draft
wfxr wants to merge 9 commits into
tikv:masterfrom
wfxr:issue-11131-gc-read-cancellation
Draft

gc: make GC state reads respect request cancellation#11136
wfxr wants to merge 9 commits into
tikv:masterfrom
wfxr:issue-11131-gc-read-cancellation

Conversation

@wfxr

@wfxr wfxr commented Aug 12, 2026

Copy link
Copy Markdown
Member

What problem does this PR solve?

Issue Number: Close #11131

GC state read requests continue waiting for the internal etcd operation timeout after the caller has canceled the gRPC or HTTP request. Because the manager holds its read lock while loading GC state, the abandoned request can also delay leadership transitions and other operations that require the write lock.

What is changed and how does it work?

Propagate request contexts through GC state manager reads, GC state
transactions, and etcd-backed Range and Txn operations so canceled requests
stop blocked storage operations promptly.

Add opt-in context-aware storage capabilities while preserving the existing
contextless interfaces for compatibility. Backends that do not implement the
new capabilities return an explicit error instead of silently falling back to
non-cancelable I/O.

Preserve the manager's existing locking, cache, transaction, and singleflight
semantics. Canceled reads release the manager read lock and do not populate the
current keyspace cache.

Return standard gRPC cancellation and deadline status codes only when the RPC
request context itself has ended. Internal etcd operation timeouts retain the
existing protobuf error-header behavior.

Check List

Tests

  • Unit test

Release note

Fix an issue where canceled GC state read requests could continue waiting for the internal etcd timeout and delay PD leadership transitions.

wfxr added 8 commits August 11, 2026 22:27
Document the approved context propagation boundary for issue tikv#11131.

Define locking, error, compatibility, and deterministic test semantics.

Signed-off-by: Wenxuan Zhang <wenxuangm@gmail.com>
Signed-off-by: Wenxuan Zhang <wenxuangm@gmail.com>
Signed-off-by: Wenxuan Zhang <wenxuangm@gmail.com>
Signed-off-by: Wenxuan Zhang <wenxuangm@gmail.com>
Signed-off-by: Wenxuan Zhang <wenxuangm@gmail.com>
Signed-off-by: Wenxuan Zhang <wenxuangm@gmail.com>
Signed-off-by: Wenxuan Zhang <wenxuangm@gmail.com>
Signed-off-by: Wenxuan Zhang <wenxuangm@gmail.com>
@ti-chi-bot

ti-chi-bot Bot commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@ti-chi-bot ti-chi-bot Bot added release-note Denotes a PR that will be considered when it comes time to generate release notes. do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. dco-signoff: yes Indicates the PR's author has signed the dco. labels Aug 12, 2026
@ti-chi-bot

ti-chi-bot Bot commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign andremouche for approval. For more information see the Code Review Process.
Please ensure that each of them provides their approval before proceeding.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@coderabbitai

coderabbitai Bot commented Aug 12, 2026

Copy link
Copy Markdown

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 63a85692-1acb-48de-9d55-4f3bde39627f

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@ti-chi-bot ti-chi-bot Bot added the size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. label Aug 12, 2026
Signed-off-by: Wenxuan Zhang <wenxuangm@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dco-signoff: yes Indicates the PR's author has signed the dco. do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

gc: GetGCState ignores request cancellation during storage reads

1 participant