-
Notifications
You must be signed in to change notification settings - Fork 720
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
region_syncer: fix blocking bugs through ctx #3766
Conversation
[REVIEW NOTIFICATION] This pull request has not been approved. To complete the pull request process, please ask the reviewers in the list to review by filling The full list of commands accepted by this bot can be found here. Reviewer can indicate their review by submitting an approval review. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you list the main changes?
Ping |
Moved part of PR to #3808 . This PR will focus on fixing bugs caused by ctx. |
Signed-off-by: HunDunDM <hundundm@gmail.com>
Signed-off-by: HunDunDM <hundundm@gmail.com>
Signed-off-by: HunDunDM <hundundm@gmail.com>
Signed-off-by: HunDunDM <hundundm@gmail.com>
err = syncStream.Send(&pdpb.SyncRegionRequest{ | ||
Header: &pdpb.RequestHeader{ClusterId: s.server.ClusterID()}, | ||
Member: s.server.GetMemberInfo(), | ||
StartIndex: s.history.GetNextIndex(), | ||
}) | ||
if err != nil { | ||
return syncStream, errs.ErrGRPCSend.Wrap(err).FastGenWithCause() | ||
return nil, errs.ErrGRPCSend.Wrap(err).FastGenWithCause() | ||
} | ||
|
||
return syncStream, nil | ||
} | ||
|
||
// StartSyncWithLeader starts to sync with leader. | ||
func (s *RegionSyncer) StartSyncWithLeader(addr string) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mark 1
@@ -40,33 +41,24 @@ const ( | |||
// StopSyncWithLeader stop to sync the region with leader. | |||
func (s *RegionSyncer) StopSyncWithLeader() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mark 2
return nil, errors.WithStack(err) | ||
} | ||
|
||
s.mu.Lock() | ||
s.mu.regionSyncerCtx, s.mu.regionSyncerCancel = ctx, cancel |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mark 3
Signed-off-by: HunDunDM <hundundm@gmail.com>
It seems it can be more likely block at here pd/server/region_syncer/client.go Line 120 in 0a35608
|
@HunDunDM: PR needs rebase. 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/test-infra repository. |
The key part of this PR has been merged in #4175 , and the remaining part will be resubmitted in the new PR. |
What problem does this PR solve?
ref #3697
The region_syncer server sometimes takes 10 minutes to exit. The following possibilities were discovered:
ctx
corresponding toMark 3
will not be canceled normally. Therefore, the client cannot immediately disconnect from the server.StartSyncWithLeader
StopSyncWithLeader
establish
successsyncHistoryRegion
is in progress. This step currently needs to send all data to end and cannot be aborted.What is changed and how it works?
Check List
Tests
Code changes
Side effects
Related changes
Release note