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

Update description of tidb_replica_read variable values for follower read #18699

Closed
wants to merge 1 commit into from

Conversation

tommygood
Copy link

@tommygood tommygood commented Aug 25, 2024

First-time contributors' checklist

What is changed, added or deleted? (Required)

  • After reviewing the source code for client-go and TiDB, I noticed that some descriptions in the follower read doc do not fully align with the source code behavior and my test results.
  1. Behavior of tidb_replica_read set to leader
    • According to client-go, when tidb_replica_read is set to leader, if the leader replica's kv store is busy, which is partially determined by the tidb_load_based_replica_read_threshold, then the client-go will select the others replica to read, which can be follower or learner replicas.
    • I have updated the doc to reflect this behavior and clarify the relationship between tidb_load_based_replica_read_threshold and tidb_replica_read when set to leader.
  2. Reading from Learner Replicas
    • Since reading from learner replicas is supported in the current version, I found it necessary to distinguish between reading from follower and learner replicas.
    • There are generally no restrictions on reading from learner replicas when tidb_replica_read is set to follower, leader-and-follower, prefer-leader, or closest-replicas. However, the current documentation only mentions follower reads in these contexts.
    • More details on how replicas are chosen based on scores can be found in the client-go calculateScore.
  3. Behavior when tidb_replica_read is set to learner
    • The doc currently states that :

      When the value of tidb_replica_read is set to learner, TiDB reads data from the learner replica. If there is no learner replica in the Region, TiDB returns an error.

    • However, in my test results (under v8.1.0), when there are no learner replica and tidb_replica_read is set to learner, mysql client still can read data from tidb.This occurs because client-go will randomly choose the leader or follower replica to read.

  • Please let me know If I have misunderstood any concepts, Thanks !

Which TiDB version(s) do your changes apply to? (Required)

Tips for choosing the affected version(s):

By default, CHOOSE MASTER ONLY so your changes will be applied to the next TiDB major or minor releases. If your PR involves a product feature behavior change or a compatibility change, CHOOSE THE AFFECTED RELEASE BRANCH(ES) AND MASTER.

For details, see tips for choosing the affected versions.

  • master (the latest development version)
  • v8.4 (TiDB 8.4 versions)
  • v8.3 (TiDB 8.3 versions)
  • v8.2 (TiDB 8.2 versions)
  • v8.1 (TiDB 8.1 versions)
  • v8.0 (TiDB 8.0 versions)
  • v7.5 (TiDB 7.5 versions)
  • v7.1 (TiDB 7.1 versions)
  • v6.5 (TiDB 6.5 versions)
  • v6.1 (TiDB 6.1 versions)
  • v5.4 (TiDB 5.4 versions)
  • v5.3 (TiDB 5.3 versions)
  • v5.2 (TiDB 5.2 versions)

What is the related PR or file link(s)?

  • This PR is translated from:
  • Other reference link(s):

Do your changes match any of the following descriptions?

  • Delete files
  • Change aliases
  • Need modification after applied to another branch
  • Might cause conflicts after applied to another branch

@CLAassistant
Copy link

CLAassistant commented Aug 25, 2024

CLA assistant check
All committers have signed the CLA.

@ti-chi-bot ti-chi-bot bot added contribution This PR is from a community contributor. first-time-contributor Indicates that the PR was contributed by an external member and is a first-time contributor. labels Aug 25, 2024
Copy link

ti-chi-bot bot commented Aug 25, 2024

Welcome @tommygood!

It looks like this is your first PR to pingcap/docs 🎉.

I'm the bot to help you request reviewers, add labels and more, See available commands.

We want to make sure your contribution gets all the attention it needs!



Thank you, and welcome to pingcap/docs. 😃

Copy link

ti-chi-bot bot commented Aug 25, 2024

Hi @tommygood. 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 /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

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.

@ti-chi-bot ti-chi-bot bot added the needs-ok-to-test Indicates a PR created by contributors and need ORG member send '/ok-to-test' to start testing. label Aug 25, 2024
Copy link

ti-chi-bot bot commented Aug 25, 2024

[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 qiancai for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found 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

@ti-chi-bot ti-chi-bot bot added missing-translation-status This PR does not have translation status info. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Aug 25, 2024
@tommygood tommygood force-pushed the update-follower-read branch from 1fdc4e0 to f3095fa Compare August 25, 2024 08:23
@qiancai qiancai requested a review from cfzjywxk August 29, 2024 00:53
@cfzjywxk
Copy link
Contributor

cfzjywxk commented Oct 9, 2024

@tommygood

Sorry for the late response, thanks for your feedback.

Some of the functional behavior descriptions mentioned above do indeed differ from the actual code implementation as you have mentioned in this PR. My thought is to separate the description of the functionality design from the error handling logic, as users are primarily concerned with the behavior of the functionality itself.

Error handling and retries are part of a more complex internal process (Ref: tikv/client-go#1167) and may require a separate document for detailed explanation.

@tommygood
Copy link
Author

Got it, thanks for your response.

@tommygood tommygood closed this Oct 9, 2024
@tommygood tommygood deleted the update-follower-read branch October 9, 2024 11:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contribution This PR is from a community contributor. first-time-contributor Indicates that the PR was contributed by an external member and is a first-time contributor. missing-translation-status This PR does not have translation status info. needs-ok-to-test Indicates a PR created by contributors and need ORG member send '/ok-to-test' to start testing. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants