If database takes longer to start, recorder fails and needs a manual restart - how to avoid it?

Hi,

I am running HA OS on a spare laptop using Qemu, all works fine. I am also using PostgreSQL with Timescale (via addon) as my database for recorder.

However, when I have to restart the laptop running this, the HA comes up, but as the addon with the DB takes a minute longer to start, HA recorder cannot connect and fails, leaving HA running, but none of history working, showing up tons of errors. I have to manually restart HA instance itself after a minute (e.g. in http://hainstance:8123/config/system via the button in the top left), and then everything works as expected.

I found out there are more people having this problem, scattered here and there.

Is there a way how I can either:

  1. let the recorder wait longer
  2. add some timeout and retry policy
  3. make HA restart when the DB becomes available

?

Did you play with db_max_retries and db_retry_wait of the recorder, already?

1 Like

Oh, that’s embarrassing… Sorry.

I am adding:

recorder:
  db_url: "postgresql://...@77b2833f-timescaledb/homeassistant"
  db_max_retries: 20
  db_retry_wait: 20

and expect that to be fixed. Will test it properly, but I think this is solved.