planner, executor: allow tidb_request_source_type and tidb_low_resolution_tso in SET_VAR hints - #70797
Conversation
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: trueThanks 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 |
|
Hi @cgtz. Thanks for your PR. I'm waiting for a pingcap 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 @cgtz! |
|
Casey Getz seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account. You have signed the CLA already but the status is still pending? Let us recheck it. |
fbc05ac to
b4bf4e0
Compare
b4bf4e0 to
58bd6ad
Compare
…tion_tso in SET_VAR hints Mark both variables as verified hint-updatable so they can be scoped to a single statement. A SET_VAR on tidb_request_source_type is also pushed into an active transaction and restored with the session variable, because the transaction copies the request source type when it is activated. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
58bd6ad to
3571ae7
Compare
|
[FORMAT CHECKER NOTIFICATION] Notice: To remove the For example:
📖 For more info, you can check the "Contribute Code" section in the development guide. |
1 similar comment
|
[FORMAT CHECKER NOTIFICATION] Notice: To remove the For example:
📖 For more info, you can check the "Contribute Code" section in the development guide. |
|
[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 |
What problem does this PR solve?
Issue Number: close #70796
Problem Summary:
tidb_request_source_typeandtidb_low_resolution_tsocan only be set for a whole session. Applications that share connections cannot tag a single query with a request source or let a single query read with a low-resolution TSO without affecting every following statement on the connection.What changed and how does it work?
Both variables are now accepted by the
SET_VARoptimizer hint, so they can be scoped to one statement:pkg/sessionctx/variable/setvar_affect.go: mark both variables as verified hint-updatable.pkg/executor/select.go: when the hinted variables are restored at the start of the next statement, also restore the transaction's request source type. The transaction copies the request source type once when it is activated and shares that struct with its snapshots, so the hinted value reaches the transaction through the statement's snapshot but was never undone, and a followingCOMMITwould prewrite/commit with the hinted source.TestRequestSourcecovers this.tidb_low_resolution_tsoneeds no extra plumbing because the read TSO is requested after hints are applied.Check List
Tests
Side effects
Documentation
Release note