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

apiutil/middleware: add retry logic for obtaining PD leader in redirector #8216

Merged
merged 1 commit into from
May 27, 2024

Conversation

JmPotato
Copy link
Member

What problem does this PR solve?

Issue Number: close #8142.

What is changed and how does it work?

Add retry logic to improve PD HTTP request forwarding success rate during PD leader switch.

Check List

Tests

  • Unit test
  • Integration test

Release note

None.

@JmPotato JmPotato added the component/api HTTP API. label May 27, 2024
@JmPotato JmPotato requested review from rleungx and HuSharp May 27, 2024 04:13
Copy link
Contributor

ti-chi-bot bot commented May 27, 2024

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • HuSharp
  • rleungx

To complete the pull request process, please ask the reviewers in the list to review by filling /cc @reviewer in the comment.
After your PR has acquired the required number of LGTMs, you can assign this pull request to the committer in the list by filling /assign @committer in the comment to help you merge this pull request.

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

Reviewer can indicate their review by submitting an approval review.
Reviewer can cancel approval by submitting a request changes review.

@ti-chi-bot ti-chi-bot bot added release-note-none Denotes a PR that doesn't merit a release note. do-not-merge/needs-triage-completed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels May 27, 2024
Copy link

codecov bot commented May 27, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 77.33%. Comparing base (dd7f2a7) to head (1b580df).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #8216      +/-   ##
==========================================
- Coverage   77.40%   77.33%   -0.07%     
==========================================
  Files         471      471              
  Lines       61456    61478      +22     
==========================================
- Hits        47569    47544      -25     
- Misses      10323    10377      +54     
+ Partials     3564     3557       -7     
Flag Coverage Δ
unittests 77.33% <100.00%> (-0.07%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Copy link
Member

@rleungx rleungx left a comment

Choose a reason for hiding this comment

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

LGTM, but I was thinking that compared with retry in pd, will it be more reasonable to send a request to the leader directly and backoff on the client side?

@ti-chi-bot ti-chi-bot bot added the status/LGT1 Indicates that a PR has LGTM 1. label May 27, 2024
@JmPotato
Copy link
Member Author

JmPotato commented May 27, 2024

LGTM, but I was thinking that compared with retry in pd, will it be more reasonable to send a request to the leader directly and backoff on the client side?

I agree; client retry should be the most straightforward choice. However, considering that this PR only takes effect during the interval of PD leader re-election, a small internal retry attempt would be lighter and faster than having the client receive an error and then retry. The two are not in conflict.

@ti-chi-bot ti-chi-bot bot added status/LGT2 Indicates that a PR has LGTM 2. and removed status/LGT1 Indicates that a PR has LGTM 1. labels May 27, 2024
@JmPotato
Copy link
Member Author

/merge

Copy link
Contributor

ti-chi-bot bot commented May 27, 2024

@JmPotato: It seems you want to merge this PR, I will help you trigger all the tests:

/run-all-tests

You only need to trigger /merge once, and if the CI test fails, you just re-trigger the test that failed and the bot will merge the PR for you after the CI passes.

If you have any questions about the PR merge process, please refer to pr process.

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 ti-community-infra/tichi repository.

Copy link
Contributor

ti-chi-bot bot commented May 27, 2024

This pull request has been accepted and is ready to merge.

Commit hash: 1b580df

@ti-chi-bot ti-chi-bot bot added the status/can-merge Indicates a PR has been approved by a committer. label May 27, 2024
@ti-chi-bot ti-chi-bot bot merged commit beb91c1 into tikv:master May 27, 2024
19 checks passed
@JmPotato JmPotato deleted the refine_api_redirect branch May 27, 2024 07:45
@lhy1024
Copy link
Contributor

lhy1024 commented May 27, 2024

Does it need to be picked to other branches?

@JmPotato
Copy link
Member Author

Does it need to be picked to other branches?

Let's observe the effect of this change for a period of time before cherry-picking.

@ti-chi-bot ti-chi-bot added the needs-cherry-pick-release-8.1 Should cherry pick this PR to release-8.1 branch. label Jul 31, 2024
@ti-chi-bot
Copy link
Member

In response to a cherrypick label: new pull request created to branch release-8.1: #8466.

ti-chi-bot bot pushed a commit that referenced this pull request Aug 1, 2024
…ctor (#8216) (#8466)

close #8142

Add retry logic to improve PD HTTP request forwarding success rate during PD leader switch.

Signed-off-by: JmPotato <[email protected]>

Co-authored-by: JmPotato <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/api HTTP API. needs-cherry-pick-release-8.1 Should cherry pick this PR to release-8.1 branch. 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. status/can-merge Indicates a PR has been approved by a committer. status/LGT2 Indicates that a PR has LGTM 2.
Projects
None yet
5 participants