[SOLVED] All Things lost from openHab

This is normal behaviour and not a bug:

Note 2 : The jars are installed in the OSGi cache - which means that they are lost upon an openHAB distro upgrade (which cleans the cache) - you will have to manually re-install then from the marketplace. As the main use case for the start will be for testing pre-releases, I think this is acceptable.

Oh thanks, I thought that something like this is behind that case :slight_smile: However I’m curious that some bindings are work as it is a stable version and yet not included in the OH bindings…

Sometime over the last few days, my HabPanel stopped working (blank white screen) so I rebooted my OpenHab hardware and when it came back I’d lost all my Things. Using the above idea for restoring the backup file (1550469048694–org.eclipse.smarthome.core.thing.Thing.json) I am now up and running again. Just noting it here so someone is aware that this problem is still happening with v2.4.0

Paul

1 Like

These are really weird issues. I only had this issue once (when posted). Also I have to mention that for me it took a while to get a system which can be used everyday (had several issues with hardware, etc… and I just added and added the new Things to my smart home system and to openHab, so that time I had some really weird and mostly hard to solve issues…)

This just happened to me, maybe this helps someone to identify what exactly is causing this:

The openhab process ran out of java heap space (cause still to be identified, I suspect the HTTP binding I installed last).

I used sudo systemctl restart openhab2, which hung for about 5 minutes before I killed it. I checked the status off the process and it was running, but did a manual stop & start to be sure.

Now I noticed that all my things were missing.
I restarted openhab again, but still nothing.

My logs aren’t much help, as they are flooded with out of memory exceptions


Luckily I have backups!
Thanks @rlkoshak! I would have started from scratch without your comment. Saved me a lot of time and frustration.

How to watch and look through logging might help you filter out the noise should you need to.

One thing to realize is that OH periodically writes out to the JSONDB, including when OH closes down. If OH ran out of heap while it was in the middle of writing to the JSONDB, or if you kill the process while it is writing to the JSONDB, the DB will become corrupted.

I thought it would be something like that in my case.

Nice post on the logs.
Maybe you could add a part on less instead of tail and the build in search?
I always recommend less, you can scroll up and it has other useful navigation keyboard shortcuts.
Granted, for piping into grep it doesn’t matter and maybe even uses a bit less system resources.

My event logs don’t show any sign of anything weird/broken, except they stop a few days ago.
Around the same time the openhab log starts showing out of memory exceptions on every action openhab was taking (polling my devices, sending stuff to influxdb,…).

So yeah, useless to identify the cause of the out of memory exception. I’ll see if it returns, if so, I’ll remove the HTTP binding and wait again for a few days.

But things are working again as they should with the backups

You just need to pipe the grep into the less. It’s nearly impossible to write a comprehensive tutorial on this sort of thing. It’s turn into a huge text processing on Linux tutorial and I’m not up for that.

Well you’re right. It is already a great post none the less

I don’t understand why this thread marked as solved. Is there anyway to fix or improve it, sometimes I remove things but it’s not removed in thing json db files, and when i restart a bundle, my things lost all channnels. Any advice or trick to makesure things are synchronized???

You first need to unlink all Channels from the Items for that Thing, then remove the Thing.

What? Please describe step by step what you are doing and check your openhab.log when this occurs. And please provide more information about your setup:

1 Like

Because the original poster flagged a post as the solution to his posted problem.

You are describing a different problem from the OP. Please answer sihui’s question, and perhaps open a new thread.

Hi! I can confirm that this bug is still round and now if wipes out the backup as well. My Things was gone when I restarted after OH2 stopped responding. The backups for Things database are all 0 bytes.

Any news on a solutions/fix for this?

It could be discussed but I mean that this is wrongfully marked as solved, the fix for the symptom is solved (or was) but not the problem itself.

We are sitting with a not working alarm system, watering system, lightning system and automation system…not in ideal situation :stuck_out_tongue:

Best Regards
Emil

RPi user? SD card wearing out?

Thanks for a quick answer sihui!

I use RPi :slight_smile:

No I don’t think that the SD is the problem, everything else runs fine.

Thinking does not help, test it.

I was just trying to be polite, not wanting to sound superior or rude.
I am 100% sure that it is not the SD as everything else runs, SD passed checks and other backups ea. Items have been successful at the same time of later.

Back to the problem;

Can the Things be recovered when the database has not done the backups correctly?

Can I manually create all Things again with the same names and the Items will work with them?

Best Regards
Emil

This thread is marked as solved, because my original question is answered. For me the issue seems to be related to OH or server shutdown, not to some file corruption, etc… That’s why I was able to restore from backup.

You can recreate the jsondb manually, it is a textfile, however not recommended, you can run into errors easily (I did this when I had to make some changes which was easier than doing in PaperUI, but I strongly won’t recommend this).
If you have a backup use it, extract the db from it…
Basically, don’t run OH (especially if you have a huge system which has crucial automations in it - ie.: you can’t live without it) without any backup. Do some manual or (better) automated backups, daily, weekly, monthly…

1 Like

Everything else what? Other stuff running on the same RPi?

Do you have a valid backup? If so I think it is just a matter of replacing your jsondb

I’m going to guess yes but I am guessing

I don’t see how OH could ever cause this to happen unless the copying of the “live” JSON files somehow failed (hence sihui’s comment, also note that when an SD card wears out all the tests you performed could and usually will pass and the fact that other stuff is still working is irrelevant, a worn out SD card just silently and slowly starts to gather weird behavior like copying a file from one location to another results in a zero length file at the copy, and maybe not every time, the files could have been zeroed out by a file system corruption caused by a power loss as well). Once OH copies the file it never touches it again. So the original copy command to create the backup must have failed, or something else came through and deleted the file contents.

If by recovered you mean recreated than yes.

Or automatically discover them again too. Just make sure to use the same ID for the bridge (e.g. MQTT Broker Thing, Zwave Controller Thing) and al the discovered Things will get the same ID they had before also.