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: fix Stream timeout logic #5551

Merged
merged 7 commits into from Oct 10, 2022
Merged

Conversation

CabinfeverB
Copy link
Member

@CabinfeverB CabinfeverB commented Sep 26, 2022

Signed-off-by: Cabinfever_B cabinfeveroier@gmail.com

What problem does this PR solve?

Issue Number: Close #5207

What is changed and how does it work?

fix Stream timeout logic

Check List

Tests

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

After the leader recovers the service, the interval of client tso service recovery is tested. Compared with the previous worst-case recovery time of 23 seconds, the current recovery time can be controlled within one second
before
image
This PR
image

Side effects

  • Possible performance regression

Related changes

  • Need to cherry-pick to the release branch

Release note

None.

Signed-off-by: Cabinfever_B <cabinfeveroier@gmail.com>
@ti-chi-bot
Copy link
Member

ti-chi-bot commented Sep 26, 2022

[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 added do-not-merge/needs-linked-issue release-note The PR should write the release note. do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. labels Sep 26, 2022
@CabinfeverB CabinfeverB changed the title fix client: use Timer to check Stream timeout Sep 26, 2022
@codecov
Copy link

codecov bot commented Sep 26, 2022

Codecov Report

Base: 75.71% // Head: 75.68% // Decreases project coverage by -0.02% ⚠️

Coverage data is based on head (1e9e9b8) compared to base (e0061e3).
Patch coverage: 65.21% of modified lines in pull request are covered.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #5551      +/-   ##
==========================================
- Coverage   75.71%   75.68%   -0.03%     
==========================================
  Files         326      326              
  Lines       32239    32243       +4     
==========================================
- Hits        24409    24403       -6     
- Misses       5715     5725      +10     
  Partials     2115     2115              
Flag Coverage Δ
unittests 75.68% <65.21%> (-0.03%) ⬇️

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

Impacted Files Coverage Δ
client/client.go 68.91% <65.21%> (-0.72%) ⬇️
server/schedulers/shuffle_hot_region.go 55.55% <0.00%> (-10.11%) ⬇️
server/storage/kv/etcd_kv.go 78.26% <0.00%> (-7.25%) ⬇️
server/tso/tso.go 66.85% <0.00%> (-5.06%) ⬇️
tools/pd-ctl/pdctl/command/operator.go 66.66% <0.00%> (-1.15%) ⬇️
pkg/dashboard/adapter/manager.go 78.16% <0.00%> (-1.15%) ⬇️
server/schedule/hbstream/heartbeat_streams.go 72.72% <0.00%> (-1.02%) ⬇️
server/schedule/operator_controller.go 86.42% <0.00%> (-0.91%) ⬇️
server/tso/allocator_manager.go 62.66% <0.00%> (-0.65%) ⬇️
... and 21 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

Signed-off-by: Cabinfever_B <cabinfeveroier@gmail.com>
Copy link
Contributor

@nolouch nolouch left a comment

Choose a reason for hiding this comment

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

Need to test.

client/client.go Outdated
for i := 0; i < maxRetryTimes; i++ {
c.updateMember()
Copy link
Contributor

@nolouch nolouch Sep 27, 2022

Choose a reason for hiding this comment

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

Consider use ScheduleCheckLeader when createTsoStream met error.

Signed-off-by: Cabinfever_B <cabinfeveroier@gmail.com>
Signed-off-by: Cabinfever_B <cabinfeveroier@gmail.com>
@@ -347,6 +347,86 @@ func TestTSOFollowerProxy(t *testing.T) {
wg.Wait()
}

// TestUnavailableTimeAfterLeaderIsReady is used to test https://github.com/tikv/pd/issues/5207
func TestUnavailableTimeAfterLeaderIsReady(t *testing.T) {
re := require.New(t)
Copy link
Contributor

Choose a reason for hiding this comment

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

How long does this test take to run?

Copy link
Member Author

Choose a reason for hiding this comment

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

I will paste a test result

}
}
retryTimeConsuming = 0
Copy link
Member

@rleungx rleungx Sep 29, 2022

Choose a reason for hiding this comment

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

Will the new implementation timeout immediately when back to streamChoosingLoop?

Copy link
Member Author

Choose a reason for hiding this comment

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

No, it will check whether stream is created. If created, it will not timeout

Signed-off-by: Cabinfever_B <cabinfeveroier@gmail.com>
@CabinfeverB CabinfeverB changed the title client: use Timer to check Stream timeout client: fix Stream timeout logic Oct 8, 2022
@ti-chi-bot ti-chi-bot added release-note-none and removed do-not-merge/needs-linked-issue release-note The PR should write the release note. labels Oct 8, 2022
@CabinfeverB CabinfeverB marked this pull request as ready for review October 8, 2022 08:43
@ti-chi-bot ti-chi-bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Oct 8, 2022
cluster.RunServers([]*tests.TestServer{leader})
}()
wg.Wait()
t.Log(maxUnavailableTime, leaderReadyTime)
Copy link
Member

Choose a reason for hiding this comment

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

Do we need to log it?

Comment on lines 399 to 415
go func() {
defer wg.Done()
var lastTS uint64
for i := 0; i < tsoRequestRound; i++ {
var physical, logical int64
var ts uint64
physical, logical, err = cli.GetTS(context.Background())
ts = tsoutil.ComposeTS(physical, logical)
if err != nil {
maxUnavailableTime = time.Now()
continue
}
re.NoError(err)
re.Less(lastTS, ts)
lastTS = ts
}
}()
Copy link
Member

Choose a reason for hiding this comment

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

How about defining a function?

Signed-off-by: Cabinfever_B <cabinfeveroier@gmail.com>
Copy link
Contributor

@nolouch nolouch left a comment

Choose a reason for hiding this comment

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

lgtm

@ti-chi-bot ti-chi-bot added the status/LGT1 Indicates that a PR has LGTM 1. label Oct 9, 2022
@ti-chi-bot ti-chi-bot added status/LGT2 Indicates that a PR has LGTM 2. and removed status/LGT1 Indicates that a PR has LGTM 1. labels Oct 9, 2022
@ti-chi-bot
Copy link
Member

In response to a cherrypick label: new pull request created: #5580.

@ti-chi-bot
Copy link
Member

In response to a cherrypick label: new pull request created: #5581.

@ti-chi-bot
Copy link
Member

In response to a cherrypick label: new pull request created: #5582.

ti-chi-bot pushed a commit to ti-chi-bot/pd that referenced this pull request Oct 10, 2022
close tikv#5207

Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
ti-chi-bot pushed a commit to ti-chi-bot/pd that referenced this pull request Oct 10, 2022
close tikv#5207

Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
ti-chi-bot pushed a commit to ti-chi-bot/pd that referenced this pull request Oct 10, 2022
close tikv#5207

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: #5583.

ti-chi-bot pushed a commit to ti-chi-bot/pd that referenced this pull request Oct 10, 2022
close tikv#5207

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 could not be created: failed to create pull request against tikv/pd#release-6.1 from head ti-chi-bot:cherry-pick-5551-to-release-6.1: the GitHub API request returns a 403 error: {"message":"You have exceeded a secondary rate limit and have been temporarily blocked from content creation. Please retry your request again later.","documentation_url":"https://docs.github.com/rest/overview/resources-in-the-rest-api#secondary-rate-limits"}

@ti-chi-bot
Copy link
Member

In response to a cherrypick label: new pull request created: #5584.

ti-chi-bot pushed a commit to ti-chi-bot/pd that referenced this pull request Oct 10, 2022
close tikv#5207

Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
ti-chi-bot pushed a commit to ti-chi-bot/pd that referenced this pull request Oct 10, 2022
close tikv#5207

Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
ti-chi-bot pushed a commit to ti-chi-bot/pd that referenced this pull request Oct 13, 2022
close tikv#5207

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: #5599.

ti-chi-bot added a commit that referenced this pull request Oct 21, 2022
close #5207, ref #5551

fix Stream timeout logic

Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
Signed-off-by: Cabinfever_B <cabinfeveroier@gmail.com>

Co-authored-by: Yongbo Jiang <cabinfeveroier@gmail.com>
Co-authored-by: Cabinfever_B <cabinfeveroier@gmail.com>
@CabinfeverB CabinfeverB removed needs-cherry-pick-release-5.0 The PR needs to cherry pick to release-5.0 branch. needs-cherry-pick-release-5.1 Type: Need cherry pick to release-5.1 needs-cherry-pick-release-5.2 Type: Need cherry pick to release-5.2 labels Nov 1, 2022
ti-chi-bot added a commit that referenced this pull request Nov 1, 2022
close #5207, ref #5551

fix Stream timeout logic

Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
Signed-off-by: Cabinfever_B <cabinfeveroier@gmail.com>

Co-authored-by: Yongbo Jiang <cabinfeveroier@gmail.com>
Co-authored-by: Cabinfever_B <cabinfeveroier@gmail.com>
ti-chi-bot added a commit that referenced this pull request Nov 14, 2022
close #5207, ref #5551

fix Stream timeout logic

Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
Signed-off-by: Cabinfever_B <cabinfeveroier@gmail.com>

Co-authored-by: Yongbo Jiang <cabinfeveroier@gmail.com>
Co-authored-by: Cabinfever_B <cabinfeveroier@gmail.com>
@JmPotato JmPotato deleted the client_tso_retry branch March 23, 2023 05:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-cherry-pick-release-5.3 Type: Need cherry pick to release-5.3 needs-cherry-pick-release-5.4 Type: Need cherry pick to release-5.4 needs-cherry-pick-release-6.1 release-note-none 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.

The timeout value for TSO stream inaccurate
4 participants