convert 2PC in TiDB sequence diagram from PNG to Mermaid code#22560
convert 2PC in TiDB sequence diagram from PNG to Mermaid code#22560ti-chi-bot[bot] merged 2 commits intopingcap:masterfrom
Conversation
Summary of ChangesHello, 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 enhances the documentation by replacing a static image diagram with a Mermaid code block. This change aims to improve the flexibility and maintainability of the diagram, making it easier for future contributors to understand and modify the visual representation of the two-phase commit process in TiDB. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Activity
Using Gemini Code AssistThe 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 by creating a comment using either
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 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. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. 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
|
There was a problem hiding this comment.
Code Review
This is a good change to replace the image with Mermaid code, making the documentation more maintainable. I've suggested some wording improvements to the diagram to enhance clarity and fix minor grammatical issues, aligning with the documentation style guide.
| ```mermaid | ||
| --- | ||
| title: 2PC in TiDB | ||
| --- | ||
| sequenceDiagram | ||
| participant client | ||
| participant TiDB | ||
| participant PD | ||
| participant TiKV | ||
|
|
||
| client->>TiDB: begin | ||
| TiDB->>PD: get ts as start_ts | ||
|
|
||
| loop excute SQL | ||
| alt do read | ||
| TiDB->>PD: get region from PD or cache | ||
| TiDB->>TiKV: get data from TiKV or cache with start_ts | ||
| TiDB-->>client: return read result | ||
| end | ||
| alt do write | ||
| TiDB-->>TiDB: write in cache | ||
| TiDB-->>client: return write result | ||
| end | ||
| end | ||
|
|
||
| client->>TiDB: commit | ||
|
|
||
| opt start 2PC | ||
| TiDB-->>TiDB: for all keys need to write,choose first one as primary | ||
| TiDB->>TiKV: locate each key | ||
| TiDB-->>TiDB: group keys by region to [](region,keys) | ||
|
|
||
| opt prewrite with start_ts | ||
| TiDB->>TiKV: prewrite(primary_key,start_ts) | ||
| loop prewrite to each region in [](region,keys) parallelly | ||
| TiDB->>TiKV: prewrite(keys,primary_key,start_ts) | ||
| end | ||
| end | ||
|
|
||
| opt commit | ||
| TiDB-->>PD: get ts as commit_ts | ||
| TiDB-->>TiKV: commit primary with commit_ts | ||
| loop send commit to each region in [](region,keys) parallelly | ||
| TiDB->>TiKV: commit(keys,commit_ts) | ||
| end | ||
| end | ||
| end | ||
|
|
||
| TiDB-->>client: success | ||
| ``` |
There was a problem hiding this comment.
To improve clarity and readability, I've made several wording adjustments, corrected typos, and ensured consistent capitalization throughout the diagram. This makes the sequence of events in the 2PC process easier to follow.
---
title: 2PC in TiDB
---
sequenceDiagram
participant client
participant TiDB
participant PD
participant TiKV
client->>TiDB: begin
TiDB->>PD: Get timestamp as start_ts
loop Execute SQL statements
alt Read data
TiDB->>PD: Get Region from PD or cache
TiDB->>TiKV: Get data from TiKV or cache with start_ts
TiDB-->>client: Return read result
end
alt Write data
TiDB-->>TiDB: Write data to the memory cache
TiDB-->>client: Return write result
end
end
client->>TiDB: commit
opt Start 2PC
TiDB-->>TiDB: Select a primary key from the keys to be written
TiDB->>TiKV: Locate the Region for each key
TiDB-->>TiDB: Group keys by Region
opt Prewrite phase
TiDB->>TiKV: prewrite(primary_key, start_ts)
loop Prewrite secondary keys for each Region in parallel
TiDB->>TiKV: prewrite(keys, primary_key, start_ts)
end
end
opt Commit phase
TiDB->>PD: Get timestamp as commit_ts
TiDB->>TiKV: commit(primary_key, commit_ts)
loop Commit secondary keys for each Region in parallel
TiDB->>TiKV: commit(keys, commit_ts)
end
end
end
TiDB-->>client: successReferences
- The suggested changes improve the diagram's clarity, readability, and consistency, and correct grammar and spelling issues, as outlined in the repository's documentation style guide (lines 14, 20, 25). (link)
[LGTM Timeline notifier]Timeline:
|
|
@qiancai: Your lgtm message is repeated, so it is ignored. DetailsIn response to this: 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-sigs/prow repository. |
|
/approve |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: Oreoxmt The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
|
In response to a cherrypick label: new pull request created to branch |
First-time contributors' checklist
What is changed, added or deleted? (Required)
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?