-
Notifications
You must be signed in to change notification settings - Fork 53
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
Deadlock in metrics #15
Comments
@yukw777 Thanks for the report. This deadlock issue is known and documented here (last sentence under "Basics"): https://godoc.org/github.com/Unleash/unleash-client-go#hdr-Basics It was a side effect of the API design where I wanted to force people to use a listener so as not to ignore errors which as you know is bad practice in Go. In retrospect, this may have been a mistake so I have contemplated changing it, perhaps in the The additional bugs you mention there certainly sound valid so I'll try to take a look at those when I get some time. I will happily accept a PR for these too if you have something ready. I've also starting writing some unit tests for the metrics struct now so hopefully that will catch some of these issues. Thanks for the great report! |
This was previously broken because we were never passing down the boolean value from the client to the metrics struct. Doing so implies that the timer is never created so we can't read from the channel in the sync function. If metrics are disabled, there is really no reason to even run the metrics routine, so just return instead. Fixes #15
The bugs relating to disabling metrics and also the deadlocks (except for the nil Listener which is documented) should now be fixed so I'm closing this. |
There's a deadlock in how the go client handles metrics data, specifically when it handles the "sent" event. There are other issues in the codebase that were uncovered during debugging, so I'll list all of them here for now, but I'm happy to make a separate issue for each if necessary.
The deadlock happens when you don't pass in an "optional" event listener (
WithListener
) when initializing the client. The unbuffered sent channel receives a valueunleash-client-go/metrics.go
Line 186 in c586a9e
, but b/c the event listener is nil, the receiver is never started
unleash-client-go/client.go
Lines 97 to 110 in c586a9e
, so the next time a payload is sent to the sent channel, it blocks.
There are some other issues related to this bug.
WithDisableMetrics
doesn't work, b/c the value doesn't get passed into metrics from the clinet.unleash-client-go/client.go
Lines 163 to 171 in c586a9e
unleash-client-go/metrics.go
Lines 95 to 99 in c586a9e
unleash-client-go/metrics.go
Lines 80 to 84 in c586a9e
The only true workaround that works right now is to set a listener, even if it's a noop.
Happy to help out in anyway I can. Thanks!
The text was updated successfully, but these errors were encountered: