-
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
tests/server: reduce test time for heartbeat msg cannot be triggered #7998
Conversation
Signed-off-by: husharp <[email protected]>
[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. |
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## master #7998 +/- ##
==========================================
+ Coverage 77.27% 77.30% +0.03%
==========================================
Files 468 468
Lines 60890 60890
==========================================
+ Hits 47055 47074 +19
+ Misses 10291 10288 -3
+ Partials 3544 3528 -16
Flags with carried forward coverage won't be shown. Click here to find out more. |
peer := &metapb.Peer{Id: peerID, StoreId: store.GetId()} | ||
regionReq := &pdpb.RegionHeartbeatRequest{ | ||
Header: testutil.NewRequestHeader(clusterID), | ||
Region: &metapb.Region{ | ||
Id: regionID, | ||
// mock error msg to trigger stream.Recv() | ||
Id: 0, |
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.
Will it skip some processes of handle region heartbeat?
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.
yes, but this regionReq
wants to ensure the client can get the server's response.
- only call
SendScheduleCommand
will send right msg byoc.hbStreams.SendMsg(region, cmd)
DispatchFromHeartBeat
will not triggerSendScheduleCommand
Otherwise, we can only get the msg when the hbStream's keepalive is triggered, which for this test is no different than sending an error msg.
And the concurrent region heartbeat tests are handled (the purpose of this test) in the below code.
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.
I don't remember what is the purpose of this test. Does it aim to test the concurrent problem or race problem?
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.
Yes, Seems like testing(including race) for concurrent running HandleRegionHeartbeat
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.
I think core logic for this test is here
https://github.com/tikv/pd/pull/7998/files#diff-4f23e8da76548a94e6779db8719386a8eabb85ad56deca5e6271a8e162652baaR789-R818
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.
If the heartbeat process exits earlier, will it still take effect?
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.
I think this part is just like a ping
which wants to ensure the connection between the client and server.
So I think the msg of the response is unimportant :)
And I have added some breakpoints to ensure concurrent region heartbeat has been handled.
What problem does this PR solve?
Issue Number: Ref #7969
What is changed and how does it work?
Performance
can reduce test time from 5s+1min(wait for keepalive) to 5s
Why change?
Previous test want to mock client send region heartbeat to server, and then server will return msg to client.
But Previous test only can be triggered by keepalive
pd/pkg/schedule/hbstream/heartbeat_streams.go
Line 154 in f51f913
So I changed region id to 0 which will send error msg
pd/server/grpc_service.go
Lines 1279 to 1284 in 5c58ddd
and then client will get msg by
pd/pkg/schedule/hbstream/heartbeat_streams.go
Line 127 in f51f913
Check List
Tests
Release note