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: use the TSO request pool at the tsoClient level to avoid data race #8077

Merged
merged 3 commits into from
Apr 17, 2024

Conversation

JmPotato
Copy link
Member

What problem does this PR solve?

Issue Number: close #8055, ref #8076.

What is changed and how does it work?

Use the TSO request pool at the `tsoClient` level to avoid data race.

Check List

Tests

  • Unit test
  • Integration test

Release note

None.

@JmPotato JmPotato added component/client Client logic. component/tso Timestamp Oracle. labels Apr 16, 2024
@JmPotato JmPotato requested review from rleungx and HuSharp April 16, 2024 09:18
Copy link
Contributor

ti-chi-bot bot commented Apr 16, 2024

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • nolouch
  • 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. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Apr 16, 2024
@JmPotato JmPotato marked this pull request as draft April 16, 2024 09:56
@ti-chi-bot ti-chi-bot bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Apr 16, 2024
@JmPotato JmPotato force-pushed the fix_tso_pool_race branch from 7f5f1e7 to 43b4611 Compare April 16, 2024 12:34
@ti-chi-bot ti-chi-bot bot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Apr 16, 2024
@JmPotato JmPotato marked this pull request as ready for review April 16, 2024 12:48
@ti-chi-bot ti-chi-bot bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Apr 16, 2024
Copy link

codecov bot commented Apr 16, 2024

Codecov Report

Merging #8077 (2cec6b5) into master (2dd2301) will decrease coverage by 0.04%.
Report is 1 commits behind head on master.
The diff coverage is 90.00%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #8077      +/-   ##
==========================================
- Coverage   77.29%   77.26%   -0.04%     
==========================================
  Files         469      470       +1     
  Lines       61097    61104       +7     
==========================================
- Hits        47225    47212      -13     
- Misses      10313    10321       +8     
- Partials     3559     3571      +12     
Flag Coverage Δ
unittests 77.26% <90.00%> (-0.04%) ⬇️

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

@@ -838,12 +823,22 @@ func (c *client) dispatchTSORequestWithRetry(req *tsoRequest) error {
err = errs.ErrClientGetTSO.FastGenByArgs("tso client is nil")
continue
}
// Get a new request from the pool if it's nil or not from the current pool.
if req == nil || req.pool != tsoClient.tsoReqPool {
Copy link
Member

Choose a reason for hiding this comment

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

When will req.pool != tsoClient.tsoReqPool happen?

Copy link
Member Author

Choose a reason for hiding this comment

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

During the retry period, a mode switch occurred causing the tsoClient to be updated.

@ti-chi-bot ti-chi-bot bot added the status/LGT1 Indicates that a PR has LGTM 1. label Apr 17, 2024
@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 Apr 17, 2024
@JmPotato
Copy link
Member Author

/merge

Copy link
Contributor

ti-chi-bot bot commented Apr 17, 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 Apr 17, 2024

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

Commit hash: 43b4611

@ti-chi-bot ti-chi-bot bot added the status/can-merge Indicates a PR has been approved by a committer. label Apr 17, 2024
@ti-chi-bot ti-chi-bot bot merged commit db88a43 into tikv:master Apr 17, 2024
26 checks passed
@JmPotato JmPotato deleted the fix_tso_pool_race branch April 18, 2024 02:29
@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 Apr 30, 2024
@JmPotato JmPotato removed the needs-cherry-pick-release-8.1 Should cherry pick this PR to release-8.1 branch. label Apr 30, 2024
@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 Apr 30, 2024
@ti-chi-bot
Copy link
Member

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

@ti-chi-bot
Copy link
Member

In response to a cherrypick label: new pull request could not be created: failed to create pull request against tikv/pd#release-8.1 from head ti-chi-bot:cherry-pick-8077-to-release-8.1: status code 422 not one of [201], body: {"message":"Validation Failed","errors":[{"resource":"PullRequest","code":"custom","message":"A pull request already exists for ti-chi-bot:cherry-pick-8077-to-release-8.1."}],"documentation_url":"https://docs.github.com/rest/pulls/pulls#create-a-pull-request"}

ti-chi-bot bot pushed a commit that referenced this pull request Apr 30, 2024
…data race (#8077) (#8141)

close #8055, ref #8076

Use the TSO request pool at the `tsoClient` level to avoid data race.

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/client Client logic. component/tso Timestamp Oracle. 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/L Denotes a PR that changes 100-499 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.

Flaky Test TestKeyspacesServedByNonDefaultKeyspaceGroups
4 participants