-
Notifications
You must be signed in to change notification settings - Fork 10
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
Panic when an in flight request is canceled #36
Comments
For the first case: I cannot reproduce it, even if I place some wait groups to simulate the case where the Send method sends on a channel that has been closed immediately before in another goroutine. The way the Close method is designed expects the outgoing channel to be nilled out before it is closed, see here. In my attempts to reproduce this, I always get a nil channel, not a closed one. I think we might be misusing Go's memory model here. According to this, the write to For the second case: I didn't explore so deeply, but indeed it seems possible. I think the design suffers from the same memory visibility issue, see here. I therefore suggest 2 things:
|
I think that one of the main issues is that the connection calls This won't fix everything though because there still might be in flight requests and responses may arrive while a |
I would start by fixing the write visibility issues, then see if there are more issues to fix. Leaving those channels open could be a quick win in fact, I don't see any compelling reason to close them when closing the connection. |
As long as those channels are not buffered then it could be a quick win indeed. |
Hmm they are buffered. What is the problem with them being buffered? |
I thought that it would create memory issues but nevermind, they should get garbage collected regardless |
We do have to make sure we don't leak goroutines otherwise the buffered channel might never get cleaned up. |
I was trying to reproduce a
panic
race condition in a different code when I ran into 2 different "panics" so I figured it would be best to report it here. In the code that reproduces this, we are opening and closing a lot of connections fast like this:But we are also sending a ton of requests concurrently like this (on another connection):
The text was updated successfully, but these errors were encountered: