Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

First records are lost during sync when bringing database back up. #226

Closed
ErgoPraxis opened this issue Nov 28, 2024 · 2 comments
Closed

Comments

@ErgoPraxis
Copy link

Hello. This might be an edge case scenario that won't be encountered too often, but wanted to document it since I found it while testing.

Reproduce Steps

  • Have a helper button.
  • Home Assistant running.
  • TimescaleDB not running.
  • Press the helper button 5 times.
  • Bring TimescaleDB back up.
  • Query ltss table. The first couple records are missing while 3, 4, 5 are present with the correct time and state values.

To me, this means LTSS is designed to re-sync once the connection is made, but is somehow either not recognizing the first few as needing resync (is this a delay it recognizing the database is down?), or is the database not capturing the first few in the sync request (so this might be a database issue).

Setup

Home Assistant

Core 2024.11.3
Frontend 20241106.2

In a podman container from: ghcr.io/home-assistant/home-assistant:stable

TimescaleDB

docker.io/timescale/timescaledb:latest-pg17

I extended this by installing postgis (ironically, this was easier than figuring out how to get non-privledged user working in timescale/timescaledb-ha).

@freol35241
Copy link
Owner

Hi, thanks for reporting.

This is expected behaviour. LTSS tries to write a record (a new state) to the database a finite amount of times (with a delay in between). If all tries fail, the record will be dropped. We cant keep records in memory "forever" until the database comes back online.

@ErgoPraxis
Copy link
Author

Ah, that makes sense.

Good thing I moved to posgres with the record integration. I setup a podman container that will start before home assistants container. Then I created a replica timescaledb for long term storage. This setup allows me to do cools things link shutdown all the heavy lifting processes while the rpi is on battery backup.

This battery running mode is mostly why I wanted LTSS to be more flexible in dumping to the timescaledb, but it makes sense why it's not.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants