-
Notifications
You must be signed in to change notification settings - Fork 701
Update follower read and learner read descriptions #21470
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
base: master
Are you sure you want to change the base?
Conversation
Signed-off-by: zyguan <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Summary of Changes
Hello @zyguan, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!
This pull request updates the documentation for TiDB's tidb_replica_read
system variable, specifically clarifying the behavior of follower
and learner
read modes. The changes reflect recent adjustments in TiDB's replica reading logic and provide important version-specific details for older releases to ensure the documentation is accurate and up-to-date.
Highlights
follower
read mode behavior: The description fortidb_replica_read
set tofollower
has been updated. It now clarifies that TiDB also considers reading from learner replicas with equal priority, and if no follower or learner replicas are available, it will fall back to reading from the leader replica.learner
read mode behavior: The description fortidb_replica_read
set tolearner
has been revised. Previously, it stated that an error would be returned if no learner replica was available; now, it clarifies that TiDB will attempt to read from available leader or follower replicas in such cases.- Version-specific notes: A new note has been added to specify the behavior for TiDB versions up to and including v7.5, detailing that
follower
andlearner
read modes would return an error if no appropriate replicas were available, contrasting with the newer fallback behavior.
Using Gemini Code Assist
The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.
Invoking Gemini
You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command>
or @gemini-code-assist <command>
. Below is a summary of the supported commands.
Feature | Command | Description |
---|---|---|
Code Review | /gemini review |
Performs a code review for the current pull request in its current state. |
Pull Request Summary | /gemini summary |
Provides a summary of the current pull request in its current state. |
Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in issue comments and review comments. |
Help | /gemini help |
Displays a list of available commands. |
Customization
To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/
folder in the base of the repository. Detailed instructions can be found here.
Limitations & Feedback
Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments or fill out our survey to provide feedback.
You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.
Footnotes
-
Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩
[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.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request updates the documentation for follower and learner reads to reflect new behaviors in recent TiDB versions. The changes clarify that when tidb_replica_read
is set to follower
or learner
, TiDB will now fall back to other replica types if the preferred type is unavailable, instead of returning an error. My review includes suggestions to improve clarity and conciseness, and to align the text with the documentation style guide. The style guide elements referenced in this review include clarity, simplicity, readability, present tense, and second person.
@@ -33,7 +33,7 @@ Default: leader | |||
This variable is used to set the expected data read mode. | |||
|
|||
- When the value of `tidb_replica_read` is set to `leader` or an empty string, TiDB maintains its default behavior and sends all read operations to the leader replica to perform. | |||
- When the value of `tidb_replica_read` is set to `follower`, TiDB selects a follower replica of the Region to perform all read operations. | |||
- When the value of `tidb_replica_read` is set to `follower`, TiDB selects a follower replica of the Region to perform all read operations. When a Region has learner replicas, TiDB also considers reading data from learner replicas. In this case, follower replicas and learner replicas have the same priority. If there are no available follower or learner replicas in the current Region, TiDB will read from the leader replica. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For better readability and conciseness, combine the sentences describing the behavior for follower
reads. This makes the logic easier to follow.12
Style Guide References
- When the value of `tidb_replica_read` is set to `follower`, TiDB selects a follower replica of the Region to perform all read operations. When a Region has learner replicas, TiDB also considers reading data from learner replicas. In this case, follower replicas and learner replicas have the same priority. If there are no available follower or learner replicas in the current Region, TiDB will read from the leader replica. | |
- When the value of `tidb_replica_read` is set to `follower`, TiDB selects a follower replica of the Region to perform read operations. If the Region has learner replicas, TiDB also considers them for reads with the same priority. If no available follower or learner replicas exist in the current Region, TiDB reads from the leader replica. |
Footnotes
@@ -42,13 +42,18 @@ This variable is used to set the expected data read mode. | |||
- If the estimated result of a read request is greater than or equal to the value of [`tidb_adaptive_closest_read_threshold`](/system-variables.md#tidb_adaptive_closest_read_threshold-new-in-v630), TiDB prefers to select a replica in the same availability zone for read operations. To avoid unbalanced distribution of read traffic across availability zones, TiDB dynamically detects the distribution of availability zones for all online TiDB and TiKV nodes. In each availability zone, the number of TiDB nodes whose `closest-adaptive` configuration takes effect is limited, which is always the same as the number of TiDB nodes in the availability zone with the fewest TiDB nodes, and the other TiDB nodes automatically read from the leader replica. For example, if TiDB nodes are distributed across 3 availability zones (A, B, and C), where A and B each contains 3 TiDB nodes and C contains only 2 TiDB nodes, the number of TiDB nodes whose `closest-adaptive` configuration takes effect in each availability zone is 2, and the other TiDB node in each of the A and B availability zones automatically selects the leader replica for read operations. | |||
- If the estimated result of a read request is less than the value of [`tidb_adaptive_closest_read_threshold`](/system-variables.md#tidb_adaptive_closest_read_threshold-new-in-v630), TiDB can only select the leader replica for read operations. | |||
|
|||
- 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. | |||
- When the value of `tidb_replica_read` is set to `learner`, TiDB reads data from the learner replica. If there is no available learner replica in the Region, TiDB will read data from available leader or follower replicas. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To improve clarity and adhere to the style guide's preference for present tense, rephrase this sentence to be more direct and concise.12
Style Guide References
- When the value of `tidb_replica_read` is set to `learner`, TiDB reads data from the learner replica. If there is no available learner replica in the Region, TiDB will read data from available leader or follower replicas. | |
- When the value of `tidb_replica_read` is set to `learner`, TiDB reads data from the learner replica. If no learner replica is available in the Region, TiDB reads from an available leader or follower replica. |
Footnotes
> - When the value of `tidb_replica_read` is set to `follower` and no follower or learner replicas are available, TiDB returns an error. | ||
> - When the value of `tidb_replica_read` is set to `learner` and no learner replicas are available, TiDB returns an error. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To align with the style guide's recommendation of using the second person ("you"), rephrase these points. This makes the documentation more user-centric.1
Style Guide References
> - When the value of `tidb_replica_read` is set to `follower` and no follower or learner replicas are available, TiDB returns an error. | |
> - When the value of `tidb_replica_read` is set to `learner` and no learner replicas are available, TiDB returns an error. | |
- If you set `tidb_replica_read` to `follower` and no follower or learner replicas are available, TiDB returns an error. | |
- If you set `tidb_replica_read` to `learner` and no learner replicas are available, TiDB returns an error. |
First-time contributors' checklist
What is changed, added or deleted? (Required)
The description of follower-read and learner-read is inaccurate, and related behaviors have been adjusted in the newer version of tidb, so the corresponding documentation has been revised accordingly.
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.
What is the related PR or file link(s)?
Do your changes match any of the following descriptions?