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

client/tso: double-check the contexts to prevent waiting for TSO requests in closed chan #7962

Merged
merged 1 commit into from
Mar 22, 2024

Conversation

JmPotato
Copy link
Member

@JmPotato JmPotato commented Mar 21, 2024

What problem does this PR solve?

Issue Number: close #7849.

What is changed and how does it work?

This PR ensures that a `tsoRequest` could be done by double-checking the contexts to prevent waiting for TSO requests in the closed channel.

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)

Release note

None.

@JmPotato JmPotato added the component/client Client logic. label Mar 21, 2024
Copy link
Contributor

ti-chi-bot bot commented Mar 21, 2024

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • HuSharp
  • nolouch

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. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Mar 21, 2024
@JmPotato
Copy link
Member Author

/hold

@ti-chi-bot ti-chi-bot bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Mar 21, 2024
@JmPotato JmPotato changed the title client/tso: use a lock to prevent sending TSO requests to closed chan client/tso: double check the contexts to prevent sending TSO requests to closed chan Mar 21, 2024
@JmPotato JmPotato changed the title client/tso: double check the contexts to prevent sending TSO requests to closed chan client/tso: double-check the contexts to prevent sending TSO requests to closed chan Mar 21, 2024
@JmPotato JmPotato force-pushed the fix_tso_hang branch 2 times, most recently from 023828a to 7090582 Compare March 21, 2024 10:17
@JmPotato JmPotato removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Mar 21, 2024
@JmPotato JmPotato changed the title client/tso: double-check the contexts to prevent sending TSO requests to closed chan client/tso: double-check the contexts to prevent waiting for TSO requests in closed chan Mar 21, 2024
Copy link

codecov bot commented Mar 21, 2024

Codecov Report

Merging #7962 (59c3a65) into master (c2eac4b) will increase coverage by 0.03%.
The diff coverage is 75.00%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #7962      +/-   ##
==========================================
+ Coverage   73.54%   73.57%   +0.03%     
==========================================
  Files         436      436              
  Lines       48432    48451      +19     
==========================================
+ Hits        35618    35650      +32     
+ Misses       9754     9740      -14     
- Partials     3060     3061       +1     
Flag Coverage Δ
unittests 73.57% <75.00%> (+0.03%) ⬆️

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

@CabinfeverB
Copy link
Member

I'm not sure if this is effective in avoiding blocks, but the code itself is fine with me. I suggest we can test it before we consider merging?

@JmPotato
Copy link
Member Author

I'm not sure if this is effective in avoiding blocks, but the code itself is fine with me. I suggest we can test it before we consider merging?

I'm not sure if this is effective in avoiding blocks, but the code itself is fine with me. I suggest we can test it before we consider merging?

I have manually tested it, and with this PR version of PD client, TiDB will no longer encounter the TSO hang issue.

@@ -64,6 +63,13 @@ var tsoReqPool = sync.Pool{
},
}

func (req *tsoRequest) tryDone(err error) {
Copy link
Contributor

@nolouch nolouch Mar 22, 2024

Choose a reason for hiding this comment

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

why need to try? from the goroutine profile we can make sure here is no blocking.

Copy link
Member Author

Choose a reason for hiding this comment

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

A request may be revoked right after it is sent to tsoBatchController, then if we double-check the contexts and return an error, done <- err will be blocked.

…ed chan

Signed-off-by: JmPotato <ghzpotato@gmail.com>
@ti-chi-bot ti-chi-bot bot added the status/LGT1 Indicates that a PR has LGTM 1. label Mar 22, 2024
@ti-chi-bot ti-chi-bot bot removed the status/LGT1 Indicates that a PR has LGTM 1. label Mar 22, 2024
@ti-chi-bot ti-chi-bot bot added the status/LGT2 Indicates that a PR has LGTM 2. label Mar 22, 2024
@HuSharp
Copy link
Member

HuSharp commented Mar 22, 2024

/merge

Copy link
Contributor

ti-chi-bot bot commented Mar 22, 2024

@HuSharp: 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 Mar 22, 2024

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

Commit hash: 59c3a65

@ti-chi-bot ti-chi-bot bot added the status/can-merge Indicates a PR has been approved by a committer. label Mar 22, 2024
@ti-chi-bot ti-chi-bot bot merged commit fb9e2d5 into tikv:master Mar 22, 2024
25 of 26 checks passed
@JmPotato JmPotato deleted the fix_tso_hang branch March 22, 2024 05:22
@ti-chi-bot ti-chi-bot added the needs-cherry-pick-release-7.1 Should cherry pick this PR to release-7.1 branch. label Apr 18, 2024
ti-chi-bot pushed a commit to ti-chi-bot/pd that referenced this pull request Apr 18, 2024
close tikv#7849

Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
@ti-chi-bot
Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/client Client logic. 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
Development

Successfully merging this pull request may close these issues.

(pdms)tpcc continues to report a lot of Error 8027 after disable/enable ms mode
5 participants