You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
While debugging a high CPU consumption in my project, I noticed that each time an event is sent to Kafka, the number of goroutines running in my project was increasing.
Adding breakpoints I see that, when writing an event, a pool is created, the code calls to unref(), ref(), unref(), ref(), unref(), leaving the value of refc as 1 but never properly canceling the context and leaving the discover goroutine running forever. On each write operation, there's a new pool created and a new discover goroutine left behind running.
I suspect that refc attribute is being used for tracking if the pool is being used or not. I don't fully understand why the code is using a uintptr for this instead of a int or any other type nor why it is being initialized with 2.
Describe the bug
While debugging a high CPU consumption in my project, I noticed that each time an event is sent to Kafka, the number of goroutines running in my project was increasing.
The code sending the event is:
After running that, I see in Intellij debug console that the number of goroutines increases:
The more events are sent, the more goroutines keep running.
Checking the code in the transport file I see that a pool of connections is initialized with a
refc: 2
here. When calling to theref()
function, it is increasing that value here. When calling theunref()
function, it decreases the value and if it's 0 it properly closes the context of that goroutine. Theunref()
function is properly called when closing the transport connections.Adding breakpoints I see that, when writing an event, a pool is created, the code calls to
unref()
,ref()
,unref()
,ref()
,unref()
, leaving the value of refc as1
but never properly canceling the context and leaving the discover goroutine running forever. On each write operation, there's a new pool created and a new discover goroutine left behind running.I suspect that
refc
attribute is being used for tracking if the pool is being used or not. I don't fully understand why the code is using auintptr
for this instead of aint
or any other type nor why it is being initialized with2
.Kafka Version
The text was updated successfully, but these errors were encountered: