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

Bug: client hangs in federation mode when connection between nodes broken. #131

Closed
DrmagicE opened this issue Jul 14, 2021 · 0 comments · Fixed by #133
Closed

Bug: client hangs in federation mode when connection between nodes broken. #131

DrmagicE opened this issue Jul 14, 2021 · 0 comments · Fixed by #133

Comments

@DrmagicE
Copy link
Owner

In federation mode, when the TCP connection between nodes gets broken, (e.g. pull the cable out), all clients will hang until the client-side close the connection.
Here is the culprit:

func (p *peer) stop() {
select {
case <-p.exit:
default:
close(p.exit)
}
p.stateMu.Lock()
if p.state == peerStateStreaming {
_ = p.stream.client.CloseSend()
}
p.state = peerStateStopped
p.stateMu.Unlock()
p.stream.wg.Wait()
}

CloseSend() will not close the underlying TCP connection of the gRPC streaming, it will wait for the response from the server and then close the connection.

if p.state == peerStateStreaming { 
 		_ = p.stream.client.CloseSend() 
} 

This will cause p.stream.wg.Wait() to hang until the connection of the gRPC streaming timeout.

Add a cancelable context.Context should fix the problem.

related to #121
reference:
grpc/grpc-go#2015 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant