-
Notifications
You must be signed in to change notification settings - Fork 442
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: runtime error: close of closed channel #99
Conversation
Hi @tylertreat can you paste the rest of the logs from that process, if possible? |
It waits several seconds and then panics. This is what it logs prior to the panic:
|
Hmmm, how long does it wait, exactly? 30 seconds? Can you share more of the code for the worker? |
Yeah, it looks like it's 30 seconds. Here's the producer/consumer code I'm using: |
Thanks, and how about a simplified example of what's using that code? I'm trying to identify where |
A very simplified example of the code using it. Basically, the publisher and subscriber are running in two different goroutines. |
If it's stalling for 30 seconds, it means something is blocked and can't make progress to exit cleanly. Can you produce a stack trace using |
Here's the full, unadulterated stack trace:
|
Well, this is suspicious - looks like
I'll look into it... |
May or may not help, but the code is actually publicly available now: https://github.com/tylertreat/Flotilla/blob/master/flotilla-server/daemon/broker/nsq/nsq.go |
Cool, thanks. P.S. now that I can see what you're building you might find this useful https://github.com/bitly/nsq/blob/master/bench/bench.py |
@tylertreat try this commit that I pushed here @jehiah RFR |
@tylertreat PS you don't need to explicitly disconnect from nsqd in func (n *NSQPeer) Teardown() {
n.producer.Stop()
if n.consumer != nil {
n.consumer.Stop()
<-n.consumer.StopChan
}
} |
Unfortunately, I still seem to be running into the same issue, even with that change:
|
There's still something blocking, would you mind pasting the Thanks for your help debugging... |
I'm not seeing the producer goroutine from before.
|
So strange, there's no NSQ code even left in the trace 😭 What commands can I run to reproduce on my own? Also what version of Go are you using? |
Yeah, basically it looks like I've tried this with Go 1.3 and 1.4. You can try running flotilla locally if you want. If you don't have Docker/boot2docker installed, you could just point it to NSQ running on localhost. Just comment out the orchestrator Start/Stop code and point it to localhost instead. Then just start the daemon with
You should see the benchmark complete and get the results back. Then the daemon panics 30 seconds later. |
😆 Ok, now that I see how this thing works... it never occurred to me that the process was long-lived. The commit here does fix the "blocking" issue that we saw in the original stack trace but there's another bug for long lived processes where I'll fix, thanks! |
@tylertreat pushed another commit, I can now run 2 successful runs and the daemon no longer panics:
|
really ready @jehiah |
panic: runtime error: close of closed channel
Yup, looks good on my end. Thanks for tracking that down and fixing it @mreiferson! |
I'm guessing this is user error, but I'm getting a panic when stopping a consumer as of this commit: 4e74fa1. Reading the comment in there, I'm trying to understand what's going on.
My shutdown code looks something like this:
Here's the error:
Can anyone provide some insight on why I'm seeing this now?