Problem with recorder after upgrading to 2024.4.3

Hi, I’ve been trying to upgrade to 2024.4.3 but every time I do this I get issues with recorder. Luckily I have been able to revert to the previous version without issue.

I think I can see a message about mariadb in the logs, and also something about history (although that might depend on recorder). I attach a section of my log at the bottom of this message. Has anyone had similar issue or is there a known fix?

Regards,

Martin

MySQLdb.OperationalError: (2005, “Unknown server host ‘core-mariadb’ (-5)”)

The above exception was the direct cause of the following exception:

Traceback (most recent call last):

File “/usr/src/homeassistant/homeassistant/components/recorder/core.py”, line 940, in _setup_recorder

self._setup_connection()

File “/usr/src/homeassistant/homeassistant/components/recorder/core.py”, line 1443, in _setup_connection

Base.metadata.create_all(self.engine)

File “/usr/local/lib/python3.12/site-packages/sqlalchemy/sql/schema.py”, line 5825, in create_all

bind._run_ddl_visitor(

File “/usr/local/lib/python3.12/site-packages/sqlalchemy/engine/base.py”, line 3254, in _run_ddl_visitor

with self.begin() as conn:

File “/usr/local/lib/python3.12/contextlib.py”, line 137, in enter

return next(self.gen)

^^^^^^^^^^^^^^

File “/usr/local/lib/python3.12/site-packages/sqlalchemy/engine/base.py”, line 3244, in begin

with self.connect() as conn:

^^^^^^^^^^^^^^

File “/usr/local/lib/python3.12/site-packages/sqlalchemy/engine/base.py”, line 3280, in connect

return self._connection_cls(self)

^^^^^^^^^^^^^^^^^^^^^^^^^^

File “/usr/local/lib/python3.12/site-packages/sqlalchemy/engine/base.py”, line 148, in init

Connection._handle_dbapi_exception_noconnection(

File “/usr/local/lib/python3.12/site-packages/sqlalchemy/engine/base.py”, line 2444, in _handle_dbapi_exception_noconnection

raise sqlalchemy_exception.with_traceback(exc_info[2]) from e

File “/usr/local/lib/python3.12/site-packages/sqlalchemy/engine/base.py”, line 146, in init

self._dbapi_connection = engine.raw_connection()

^^^^^^^^^^^^^^^^^^^^^^^

File “/usr/local/lib/python3.12/site-packages/sqlalchemy/engine/base.py”, line 3304, in raw_connection

return self.pool.connect()

^^^^^^^^^^^^^^^^^^^

File “/usr/local/lib/python3.12/site-packages/sqlalchemy/pool/base.py”, line 449, in connect

return _ConnectionFairy._checkout(self)

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File “/usr/local/lib/python3.12/site-packages/sqlalchemy/pool/base.py”, line 1263, in _checkout

fairy = _ConnectionRecord.checkout(pool)

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File “/usr/local/lib/python3.12/site-packages/sqlalchemy/pool/base.py”, line 712, in checkout

rec = pool._do_get()

^^^^^^^^^^^^^^

File “/usr/local/lib/python3.12/site-packages/sqlalchemy/pool/impl.py”, line 179, in _do_get

with util.safe_reraise():

File “/usr/local/lib/python3.12/site-packages/sqlalchemy/util/langhelpers.py”, line 146, in exit

raise exc_value.with_traceback(exc_tb)

File “/usr/local/lib/python3.12/site-packages/sqlalchemy/pool/impl.py”, line 177, in _do_get

return self._create_connection()

^^^^^^^^^^^^^^^^^^^^^^^^^

File “/usr/local/lib/python3.12/site-packages/sqlalchemy/pool/base.py”, line 390, in _create_connection

return _ConnectionRecord(self)

^^^^^^^^^^^^^^^^^^^^^^^

File “/usr/local/lib/python3.12/site-packages/sqlalchemy/pool/base.py”, line 674, in init

self.__connect()

File “/usr/local/lib/python3.12/site-packages/sqlalchemy/pool/base.py”, line 900, in __connect

with util.safe_reraise():

File “/usr/local/lib/python3.12/site-packages/sqlalchemy/util/langhelpers.py”, line 146, in exit

raise exc_value.with_traceback(exc_tb)

File “/usr/local/lib/python3.12/site-packages/sqlalchemy/pool/base.py”, line 896, in __connect

self.dbapi_connection = connection = pool._invoke_creator(self)

^^^^^^^^^^^^^^^^^^^^^^^^^^

File “/usr/local/lib/python3.12/site-packages/sqlalchemy/engine/create.py”, line 643, in connect

*return dialect.connect(*cargs, *cparams)

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File “/usr/local/lib/python3.12/site-packages/sqlalchemy/engine/default.py”, line 617, in connect

*return self.loaded_dbapi.connect(*cargs, *cparams)

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File “/usr/local/lib/python3.12/site-packages/MySQLdb/init.py”, line 121, in Connect

*return Connection(*args, *kwargs)

^^^^^^^^^^^^^^^^^^^^^^^^^^^

File “/usr/local/lib/python3.12/site-packages/MySQLdb/connections.py”, line 195, in init

*super().init(*args, *kwargs2)

sqlalchemy.exc.OperationalError: (MySQLdb.OperationalError) (2005, “Unknown server host ‘core-mariadb’ (-5)”)

(Background on this error at: Error Messages — SQLAlchemy 2.0 Documentation)

2024-04-21 15:28:58.570 ERROR (MainThread) [homeassistant.setup] Setup failed for ‘recorder’: Integration failed to initialize.

2024-04-21 15:29:02.157 ERROR (MainThread) [homeassistant.setup] Unable to set up dependencies of ‘history’. Setup failed for dependencies: [‘recorder’]

2024-04-21 15:29:02.158 ERROR (MainThread) [homeassistant.setup] Setup failed for ‘history’: Could not setup dependencies: recorder

2024-04-21 15:29:02.166 ERROR (MainThread) [homeassistant.setup] Unable to set up dependencies of ‘energy’. Setup failed for dependencies: [‘history’, ‘recorder’]

I have fixed this by updating my configure.yaml as I was using mariadb which doesn’t appear to work in this version of Home Assistant. After removing the db_url statement under recorder (which causes HA to default to using sqlite) my install is now working again with the original DB.
No-one else appears to have had the same issue so I wasn’t expecting a fix.

Regards,

Martin

That’s not really a “fix”. The bigger issue is that the upgrade didn’t seem to notice your MariaDB addon as existing or running. I would actually try to solve that first and then try to upgrade again. Was the addon running at the time you tried to upgrade? Was the addon itself upgraded to the latest version?

1 Like

To be fair there was an update of mariadb just before the Home Asssistant update so it may be that which caused the problem. You are right though. I didn’t fix it. I just thought I should update my post for anyone who comes afterwards with the same issue.
I forget why I installed mariadb now, so it will probably come up again eventually.

Regards,

Martin

1 Like

Ohh sorry to answer your question I had just upgraded MariaDB although really only to ensure I was running the latest version.

Martin

1 Like

To be fair, if you have a small to medium HA instance, running on the default DB is fine (so long as you tune it properly using recorder). MariaDB is nice and all, but typically it’s overkill for most HA instances (all this is my personal opinion).

I think I installed MariaDB back in the days when I was running on an older Pi 3. I’m not using a pi 5 yet but I was just pondering it. My pi 4 seems happy enough though really.

Martin

I typically tell people that unless you are looking to capture a lot of data and statistics (or you are building your system for redundancy), an external DB is the way to go.

But if you’re running on a rPi4 with a small to medium install, I’d just stick with the built-in DB. The HA devs have done an amazing job tuning it and making it so much better than it was.