home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
72.17k stars 30.2k forks source link

reload race with Hue Bridge #111784

Closed Anto79-ops closed 2 weeks ago

Anto79-ops commented 7 months ago

The problem

hello,

Just installed HA 2024.3.0b0 core beta, and when enabling this logging in config.yaml,

logger:
  default: info
  logs:
    homeassistant.loader: debug

and this was logged.

2024-02-28 15:45:20.592 ERROR (MainThread) [homeassistant.core] Unable to remove unknown job listener (<Job onetime listen homeassistant_started functools.partial(<bound method ConfigEntry._async_setup_again of <ConfigEntry entry_id=daea4f025b75e7641e83b7572864cc2a version=1 domain=hue title=Hue Bridge ecb5fa9d04a6 state=ConfigEntryState.SETUP_RETRY unique_id=ecb5fa9d04a6>>, <HomeAssistant NOT_RUNNING>) HassJobType.Callback <_OneTimeListener functools:functools.partial(<bound method ConfigEntry._async_setup_again of <ConfigEntry entry_id=daea4f025b75e7641e83b7572864cc2a version=1 domain=hue title=Hue Bridge ecb5fa9d04a6 state=ConfigEntryState.SETUP_RETRY unique_id=ecb5fa9d04a6>>, <HomeAssistant RUNNING>)>>, None, False)
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/core.py", line 1407, in _async_remove_listener
    self._listeners[event_type].remove(filterable_job)
    ~~~~~~~~~~~~~~~^^^^^^^^^^^^
KeyError: 'homeassistant_started'
2024-02-28 15:45:21.004 INFO (SyncWorker_5) [homeassistant.loader] Loaded intent from homeassistant.components.intent
2024-02-28 15:45:21.118 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 1603, in async_reload
    unload_result = await self.async_unload(entry_id)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 1575, in async_unload
    raise OperationNotAllowed(
homeassistant.config_entries.OperationNotAllowed: The config entry Hue Bridge ecb5fa9d04a6 (hue) with entry_id daea4f025b75e7641e83b7572864cc2a cannot be unloaded because it is not in a recoverable state (ConfigEntryState.SETUP_IN_PROGRESS)

maybe related to this isssue https://github.com/home-assistant/core/issues/109722

CC @bdraco for more information

What version of Home Assistant Core has the issue?

2024.3.0b0

What was the last working version of Home Assistant Core?

2024.2.x

What type of installation are you running?

Home Assistant OS

Integration causing the issue

Hue

Link to integration documentation on our website

https://www.home-assistant.io/integrations/hue/

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

No response

Additional information

No response

home-assistant[bot] commented 7 months ago

Hey there @balloob, @marcelveldt, mind taking a look at this issue as it has been labeled with an integration (hue) you are listed as a code owner for? Thanks!

Code owner commands Code owners of `hue` can trigger bot actions by commenting: - `@home-assistant close` Closes the issue. - `@home-assistant rename Awesome new title` Renames the issue. - `@home-assistant reopen` Reopen the issue. - `@home-assistant unassign hue` Removes the current integration label and assignees on the issue, add the integration domain after the command. - `@home-assistant add-label needs-more-information` Add a label (needs-more-information, problem in dependency, problem in custom component) to the issue. - `@home-assistant remove-label needs-more-information` Remove a label (needs-more-information, problem in dependency, problem in custom component) on the issue.

(message by CodeOwnersMention)


hue documentation hue source (message by IssueLinks)

bdraco commented 7 months ago

It looks like hue is being reloaded in a task but its still in progress

probably from the reload listener

bdraco commented 7 months ago

If the integration is setup and the config entry gets updated https://github.com/home-assistant/core/blob/0985a7ab91cb59ad7d599eb474bbd6e388155b3f/homeassistant/components/hue/config_flow.py#L228 this can cause a reload and than the reload listener fires and reloads as well

bdraco commented 7 months ago

This doesn't look like a regression though in 2024.3.x so I'm going to drop the milestone as its likely been a problem for a while, and the impact is only the log message since the config entries internals prevents the race

marcelveldt commented 6 months ago

Not sure what I can do about this from Hue perspective as its basically just the config flow handlers handling the race. Bit of an edge case of an edge case and yet probbaly at core/config flow level and not integration level.

issue-triage-workflows[bot] commented 3 months ago

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment πŸ‘ This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

Anto79-ops commented 3 months ago

keep alive, thanks :)

issue-triage-workflows[bot] commented 3 weeks ago

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment πŸ‘ This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.