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

test: update client state subscriber test to be not flaky and more stressful about rapid updates #6512

Merged
merged 8 commits into from
Aug 10, 2023

Conversation

dfawley
Copy link
Member

@dfawley dfawley commented Aug 8, 2023

RELEASE NOTES: none

@dfawley dfawley added this to the 1.58 Release milestone Aug 8, 2023
@dfawley dfawley requested a review from easwars August 8, 2023 18:53
easwars
easwars previously approved these changes Aug 8, 2023
test/clientconn_state_transition_test.go Outdated Show resolved Hide resolved
@easwars easwars assigned dfawley and unassigned easwars Aug 8, 2023
@dfawley dfawley assigned easwars and unassigned dfawley Aug 8, 2023
@dfawley dfawley requested a review from easwars August 9, 2023 15:57
clientconn.go Outdated
@@ -1234,6 +1230,7 @@ func (cc *ClientConn) ResetConnectBackoff() {

// Close tears down the ClientConn and all underlying connections.
func (cc *ClientConn) Close() error {
defer func() { <-cc.csMgr.pubSub.Done() }()
Copy link
Contributor

Choose a reason for hiding this comment

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

This is now executed outside of cc.mu. Was that intentional?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes. cc.cancel() needs to happen or else pubSub.Done() will never close. And csMgr isn't protected by cc.mu so it should be fine.

Copy link
Contributor

Choose a reason for hiding this comment

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

Optional: Maybe a single defer instead of two? Even when we know that deferred funcs are executed LIFO, this is easier to read than having two defers I feel.

defer func() {
  cc.cancel()
  <-cc.csMgr.pubSub.Done()
}()

Copy link
Member Author

Choose a reason for hiding this comment

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

SGTM - done

internal/grpcsync/callback_serializer.go Outdated Show resolved Hide resolved
internal/grpcsync/pubsub.go Outdated Show resolved Hide resolved
@easwars easwars assigned dfawley and unassigned easwars Aug 9, 2023
@dfawley dfawley assigned easwars and unassigned dfawley Aug 9, 2023
clientconn.go Outdated
@@ -1234,6 +1230,7 @@ func (cc *ClientConn) ResetConnectBackoff() {

// Close tears down the ClientConn and all underlying connections.
func (cc *ClientConn) Close() error {
defer func() { <-cc.csMgr.pubSub.Done() }()
Copy link
Contributor

Choose a reason for hiding this comment

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

Optional: Maybe a single defer instead of two? Even when we know that deferred funcs are executed LIFO, this is easier to read than having two defers I feel.

defer func() {
  cc.cancel()
  <-cc.csMgr.pubSub.Done()
}()

@easwars easwars assigned dfawley and unassigned easwars Aug 10, 2023
@dfawley dfawley merged commit 879faf6 into grpc:master Aug 10, 2023
1 check passed
@dfawley dfawley deleted the connstatetest branch August 11, 2023 15:03
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 8, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants