Restart recorder service and detect unavailability

It should generate errors in the log which you can monitor with an event trigger.

Possibly with a shell command. That would depend on what you are using as a recorder.

I have no idea how to implement the specifics of either of these things.

I’m using a external MariaDB DB as recorder. However, I think it should be possible to reload the recorder configuration or even change it.

If the connection is lost, it doesn’t reconnect automatically.

Sure, you can restart external services…

I just don’t know what that command would be.

The external MariaDB is fine. But once the service is unavailable it doesn’t reconnect even if the external MariaDB is working fine.

If it would be fine, it would never become unavailable :wink:
Maybe try to fix that root cause rather than trying to implement complicated workarounds?

I assume it is due to network issues. If I restart home assistant it starts logging again. What could I do then?

Firstly, show us the exact log messages when the recorder starts to fail.
Secondly, and obviously, if it’s actually a network issue, you should fix that.

I’m just asking if there is any way to reload/restart lthe recorder service without restarting HA.
Disabling and enabling back doesn’t wlork.

I restarted and lost the logs. Once I have them I’ll post them back.

Then the answer is no.

I doubt that Recorder is “unavailable” to HA, Recorder is 1 of the first thing HA “sets up”, Configurations such as db_url , etc comes from conf…yaml … so what becomes “unavailable” is most likely your “MariaDB” , Not the Recorder Service on HA … a proper Network-Setup is AO for an External DB to not get “lost connections” and of cause that HA is “capable” of keeping the connection, to external “re-sources”, as i.e a DB, DNS, Router, Zigbee-wifi-hub, Cast-Device etc

I.E Could be of interest to see you Recorder “Settings” and DB Settings in Conf…yaml … if you have “Very Limited” Records, you might want to either increase db_max_retries( if for some reason your “connection”(somewhere) has gone into “sleep_mode” ( i strongly assume you don’t have your MariaDB on a “default” windows_machine ) , … or “create” a “Dummy” to “store” (more often) … But these “suggestions” seems more like “Workarounds” :wink:
PS: i do believe i.e Tracker helps HA keeping “contact” with it’s “environment”

OK. I got the problem again, these are the logs. First, I got this:
image

Then, I got this:

And, finally, this error:

And recorder became unavailable.

This are my recorder settings:
image

After this no events are being recorded anymore. I had to restart home assistant, because I only have the latest value available.

The first thing I would try is remove the last three lines that limit the recorder. Then I would check if you, especially with mariaDB, set up a max. amount of connections on your Database side. for example if you use DBeaver as a way to access your database you can set these limits for the user you set up for your database.

I don’t understand what lines are limiting what. They are increasing the default values.

so why did you add these lines, if you dont know what they do ? … have you even looked in your DB-logs ? … i mean you have timestamp in HA, when the errors occurs … try to compare them with what the DB logs say

I know what they do. But is the opposite of what @Timaelly says, they increase the retries, thus being less limited.

And yes, I have. But I have found no clue.

I had a similar concern but I notice that if the database server goes offline the recorder resumes logging when it comes back online. This is the point of the retry?
I discovered that my HAS had come back online with only IPv6 and the database server isn’t using IPv6. I don’t know why the IPv4 was disabled so that remains a mystery.

Not in my case. When it comes back online, it doesn’t resume.

Hello All,

Is there already an solution for this?
After an power outage, both my synology and HA where down. After it powered back up, the recorder could not connect. I found out that it is because of the synology taking way longer to start up, and is not online yet when HA tries to connect. Once HA fails to connect, it does not try to reconnect at all. So i have to reboot HA once more, and it runs fine.

anyone knows an solution to force ha to reconnect automatically?

1 Like

I wish… but I haven’t seen any.

Here is a solution by increasing number of retries and timeout: If database takes longer to start, recorder fails and needs a manual restart - how to avoid it? - #3 by kotrfa