Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

*: make tidb_replica_read work with set_var hint #48156

Conversation

crazycs520
Copy link
Contributor

@crazycs520 crazycs520 commented Nov 1, 2023

cherry-pick #48473

What problem does this PR solve?

Issue Number: close #48472

Problem Summary: make tidb_read_staleness and tidb_replica_read work with set_var hint

What is changed and how it works?

This PR:

mysql> select /*+ SET_VAR(tidb_replica_read = 'follower')*/ @@tidb_replica_read;
+---------------------+
| @@tidb_replica_read |
+---------------------+
| follower            |
+---------------------+
1 row in set (0.00 sec)

mysql> select  @@tidb_replica_read;
+---------------------+
| @@tidb_replica_read |
+---------------------+
| leader              |
+---------------------+
1 row in set (0.00 sec)

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
  • No need to test
    • I checked and no code files have been changed.

Side effects

  • Performance regression: Consumes more CPU
  • Performance regression: Consumes more Memory
  • Breaking backward compatibility

Documentation

  • Affects user behaviors
  • Contains syntax changes
  • Contains variable changes
  • Contains experimental features
  • Changes MySQL compatibility

Release note

Please refer to Release Notes Language Style Guide to write a quality release note.

None

Signed-off-by: crazycs520 <crazycs520@gmail.com>
@crazycs520 crazycs520 requested a review from a team as a code owner November 1, 2023 01:58
@ti-chi-bot ti-chi-bot bot added release-note-none Denotes a PR that doesn't merit a release note. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Nov 1, 2023
Copy link

tiprow bot commented Nov 1, 2023

Hi @crazycs520. Thanks for your PR.

PRs from untrusted users cannot be marked as trusted with /ok-to-test in this repo meaning untrusted PR authors can never trigger tests themselves. Collaborators can still trigger tests on the PR using /test all.

I understand the commands that are listed here.

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/test-infra repository.

Copy link
Contributor

@Tema Tema left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@crazycs520 thanks!

Copy link

ti-chi-bot bot commented Nov 1, 2023

@Tema: adding LGTM is restricted to approvers and reviewers in OWNERS files.

In response to this:

@crazycs520 thanks!

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/test-infra repository.

@ti-chi-bot ti-chi-bot bot added needs-1-more-lgtm Indicates a PR needs 1 more LGTM. approved labels Nov 1, 2023
@cfzjywxk cfzjywxk requested a review from zyguan November 1, 2023 05:55
Copy link
Contributor

@zyguan zyguan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Setting IsHintUpdatable to true may not actually take effect, the value is cached in SessionVars.stmtVars but we still read from the field (eg SessionVars.ReadStaleness).

@cfzjywxk
Copy link
Contributor

cfzjywxk commented Nov 1, 2023

Setting IsHintUpdatable to true may not actually take effect, the value is cached in SessionVars.stmtVars but we still read from the field (eg SessionVars.ReadStaleness).

Seems to be a problem, @crazycs520 PTAL

@hawkingrei
Copy link
Member

/retest

@crazycs520
Copy link
Contributor Author

Setting IsHintUpdatable to true may not actually take effect, the value is cached in SessionVars.stmtVars but we still read from the field (eg SessionVars.ReadStaleness).

Nice catch, Currently the fix is not really work. Since SET_VAR feature is GA on v7.4.0, the SET_VAR implementation is a little different between this branch(v6.5.4) and v7.4.0. So I need another work to make tidb_read_staleness and tidb_replica_read work with set_var hint.

cc @Tema

Signed-off-by: crazycs520 <crazycs520@gmail.com>
@ti-chi-bot ti-chi-bot bot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Nov 2, 2023
Signed-off-by: crazycs520 <crazycs520@gmail.com>
Signed-off-by: crazycs520 <crazycs520@gmail.com>
@ti-chi-bot ti-chi-bot bot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Nov 6, 2023
@crazycs520 crazycs520 changed the title *: make tidb_read_staleness and tidb_replica_read work with set_var hint *: make tidb_replica_read work with set_var hint Nov 6, 2023
Signed-off-by: crazycs520 <crazycs520@gmail.com>
@ti-chi-bot ti-chi-bot bot added lgtm and removed needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Nov 6, 2023
Copy link

ti-chi-bot bot commented Nov 6, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: cfzjywxk, Tema, zyguan

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

The pull request process is described here

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

Copy link

ti-chi-bot bot commented Nov 6, 2023

[LGTM Timeline notifier]

Timeline:

  • 2023-11-01 05:54:30.101712743 +0000 UTC m=+3018867.688822888: ☑️ agreed by cfzjywxk.
  • 2023-11-06 08:19:15.789639643 +0000 UTC m=+3459553.376749788: ☑️ agreed by zyguan.

@hawkingrei
Copy link
Member

/retest

Signed-off-by: crazycs520 <crazycs520@gmail.com>
@crazycs520 crazycs520 merged commit 245230a into pingcap:tidb-6.5-with-kv-timeout-feature Nov 9, 2023
3 of 7 checks passed
@crazycs520 crazycs520 deleted the support-var-in-set-hint branch November 9, 2023 08:30
guoshouyan pushed a commit to guoshouyan/tidb that referenced this pull request Mar 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved lgtm release-note-none Denotes a PR that doesn't merit a release note. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants