Closed armin-gh closed 2 years ago
Hey there @bdraco, mind taking a look at this issue as it has been labeled with an integration (zeroconf
) you are listed as a code owner for? Thanks!
(message by CodeOwnersMention)
zeroconf documentation zeroconf source (message by IssueLinks)
Prior to creating the issue here, posted as a question in the community forums at https://community.home-assistant.io/t/thread-leak/446233
The zeroconf integration itself is all async so it is not creating any threads.
You have another integration that is using the sync api to create ServiceBrowser
s for _http._tcp
that is not canceling them when it is finished with them.
I'd look through the source code to all the PyPI packages of all the integration you have installed for the string ServiceBrowser
and try to narrow it down to ones that create them.
The bug is here https://github.com/tschamm/boschshcpy/blob/fe3c795d99824365967bacaddbd3f68bb85df64b/boschshcpy/information.py#L32
The ServiceBrowser
is never canceled
There isn't anything we can do here as the custom component needs to fix this.
The problem
running HA 2022.7.5 in a Python venv, Python 3.9, Raspberry Pi 4, 4GB, Storage on SSD Once in a while I have such a message in the log: Not related to a new install, I had observed this at least the past 6 months, if not longer. But usually I restart the system every 2nd or 3rd day after updates or configuration changes.
at around 04:50am BoschSHC integration could not start a new thread.
This time I monitored the system since restarting on 2022-07-28 17:50. Did install py-spy and found this: I have an ever increasing number of threads with this name: Thread 0xBE80E440 (active): “zeroconf-ServiceBrowser-_http._tcp-2954” Setup a sensor for monitoring:
After starting the HA-Service I have 3 such threads and it increases by 2 threads every 40-50 minutes, the maximum was 312 “zeroconf-ServiceBrowser-_http._tcp-”-Threads yesterday morning at 04:50, same time I had the error above in the logs.
Stacktrace created with
py-spy dump -s -l --pid $(pgrep -u homeassistant hass )
for all 312 threads is similar:Rule out other integrations ( BoschSHC, nmap) by disabling them. Then removed "default_config" from my configuration.yaml and started to add single integrations one at a time. After adding "zeroconf" the threads were created again.
DS416 (name listed in the stacktrace) is a Synology DS416, besides working as a fileserver it also provides DHCP- and DNS-Services here in my network.
What version of Home Assistant Core has the issue?
core-2022.7.5
What was the last working version of Home Assistant Core?
No response
What type of installation are you running?
Home Assistant Core
Integration causing the issue
Zeroconf
Link to integration documentation on our website
https://www.home-assistant.io/integrations/zeroconf/
Diagnostics information
No response
Example YAML snippet
Anything in the logs that might be useful for us?
No response
Additional information
ask if you need a logger with specific configuration, running a logger for zeroconf with "debug" was producing huge files and I stopped the logs