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

Buffer SQL statements (in a sql file) incase DB is unavailable #275

Open
Kopierwichtel opened this issue Oct 31, 2022 · 4 comments
Open

Comments

@Kopierwichtel
Copy link

Kopierwichtel commented Oct 31, 2022

Is your feature request related to a problem? Please describe.
For my parents i'm using a raspberrypi for the iobroker instance incl. the sql adapter. The db (postgresql) is stored on their windows PC to have a high performance incl. a Grafana instance. During the night the pc is turned off, leading to the problem, that no data is logged durng that period.

Describe the solution you'd like
If the DB cannot be reached the statements are saved e.g. in a sql file. Once the DB is back online again all missed changes / the SQL file is imported. After the successful import, the SQL file deleted again. My goal is to have a 24/7 protocol of all data, e.g. energy data, ... but without having to run the normal PC all night

Describe alternatives you've considered
Maybe not an alternative, but a MVP: Initially the SQL file could be stored (one file per day). The file is stored on the raspi where i can copy and import it regularly

Additional context

@Apollon77
Copy link
Contributor

Hm ... The InfluxDB adapter has a "host unavailable memory caching" and if I would add something like this I would add that.

Sorry but f you decide to log into a Database then this database should be available ... Caching several hours of data for such a case is a very special usecase

@Kopierwichtel
Copy link
Author

I don't know this feature. If it stores the values over night it fine for me ;-) Basically i agree that the DB should be online all time, but considering the energy prices i can't tel lmy parents to run the PC 24/7.

I calculated that the space consumtion is approx 2 MB per state for 8 hours assuming a new value every sec. Maybe it would be possible to define the states which shall be buffered. In my case value are only written every 10 sec and only 3 values are needed.

As aworkaround I was thinking if I can use the normal history adapter to store the value additionaly just for one day and then use a script to read those value and send them to the SQL adapter once the postgre DB is back. But i don't know if this would work.

@Apollon77
Copy link
Contributor

If it stores the values over night it fine for me ;-)

In fact it depends on your available RAM because the values are only stored in RAM and pot. lost if it crashed because of "out of memory" ... As said ... This feature is planned to handle a DB restart or such or cases with updates, so short timeframes - not a whole night.

@Kopierwichtel
Copy link
Author

ah, understood. I think in my or my parents use case it would work, because there are only 3 states which are being updated every 10 sec. If there's no coded limit it could work

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

No branches or pull requests

2 participants