All Things are gone after restarting openHAB

Hi,

I still use Ubuntu 20.04 and openHAB 3.2.0-1. After restarting openHAB I have no more Things. They are gone. All bindings are installed correctly. And all the items are there too. But logically, without Things I can’t operate any devices.

Off course I restarted openHAB multiple times. I also deleted the content in /var/lib/openhab/tmp and /var/lib/openhab/cache after stopping openHAB.

If I open the org.openhab.core.thing.Thing.json file (in the /var/lib/openhab/jsondb directory) with my editor, I can also see all missing things. But sadly if openHAB is started there are no things available. That’s confusing.

I didn’t find anything in the log files that could indicate an error. On the other hand, I don’t know what to look for. The log files are also extremely large. Of course, I could miss something.

Has anyone here had a similar problem and perhaps knows a solution? So far I have only found a solution by deleting tmp and cache or if you have a backup, how to restore the file described above with the Things. But this is apparently not the problem here.

Thanks in advance.

You need to share some logs

I think I should share a bit more knowledge.

The following file locations are used:

File location
openHAB application /usr/share/openhab
Additional add-on files /usr/share/openhab/addons
Site configuration /etc/openhab
Log files /var/log/openhab
Backups folder /var/lib/openhab/backups
Service configuration /etc/default/openhab

I have also checked that everything is assigned accordingly for openhab:openhab.

What I carried out was:

sudo systemctl stop openhab
sudo rm -r /var/lib/openhab/tmp/*
sudo rm -r /var/lib/openhab/cache/*
sudo systemctl start openhab
....
sudo systemctl restart openhab

I also stopped openHAB, and moved away the org.openhab.core.thing.Thing.json. Then I have done the steps above. Then I moved back the org.openhab.core.thing.Thing.json file. I thought maybe for reinitializing this could help.

I also restarted like described above openHAB and moved also configuration files. My thought was that maybe there was an error and before reading the Things the system was overloaded. But it seems this could not be the error.

Also I have changed the file locations in /etc/default/openhab. But this could not be the problem because I never changed using the default paths. Off course I set the default paths. And also it could not be the problem because all bindings are installed after restarting openHAB. So using as example the /usr/share/openhab/addons or /var/lib/openhab/... paths are working.

At least I have reinstalled openHAB with sudo apt install --reinstall openhab and restarted it like described above.

It’s not as if all the Things have disappeared. I have stored a few very few things in the openHAB configuration folder in text form. These are also read in correctly when the system is restarted. Only all Things, and that should be more than 90% of my Things that I created via the UI, are missing.

Attached are the log files for the events. The other one was too big, I have to upload a map separately.

events.log (300.3 KB)

Here the openhab.log. It is zipped and you can download it here:

Log file shows

2023-03-09 14:32:37.037 [WARN ] [re.storage.json.internal.JsonStorage] - Json storage file at '/var/lib/openhab/jsondb/backup/1678110157103--org.openhab.core.thing.Thing.json' is empty - ignoring corrupt file.
2023-03-09 14:32:37.176 [WARN ] [re.storage.json.internal.JsonStorage] - Json storage file at '/var/lib/openhab/jsondb/backup/1678110146877--org.openhab.core.thing.Thing.json' is empty - ignoring corrupt file.
2023-03-09 14:32:37.193 [WARN ] [re.storage.json.internal.JsonStorage] - Json storage file at '/var/lib/openhab/jsondb/backup/1678110145179--org.openhab.core.thing.Thing.json' is empty - ignoring corrupt file.
2023-03-09 14:32:37.231 [WARN ] [re.storage.json.internal.JsonStorage] - Json storage file at '/var/lib/openhab/jsondb/backup/1678110143340--org.openhab.core.thing.Thing.json' is empty - ignoring corrupt file.
2023-03-09 14:32:37.234 [WARN ] [re.storage.json.internal.JsonStorage] - Json storage file at '/var/lib/openhab/jsondb/backup/1678110141664--org.openhab.core.thing.Thing.json' is empty - ignoring corrupt file.
2023-03-09 14:40:22.219 [WARN ] [re.storage.json.internal.JsonStorage] - Json storage file at '/var/lib/openhab/jsondb/backup/1678110157103--org.openhab.core.thing.Thing.json' is empty - ignoring corrupt file.
2023-03-09 14:40:22.221 [WARN ] [re.storage.json.internal.JsonStorage] - Json storage file at '/var/lib/openhab/jsondb/backup/1678110146877--org.openhab.core.thing.Thing.json' is empty - ignoring corrupt file.
2023-03-09 14:40:22.223 [WARN ] [re.storage.json.internal.JsonStorage] - Json storage file at '/var/lib/openhab/jsondb/backup/1678110145179--org.openhab.core.thing.Thing.json' is empty - ignoring corrupt file.
2023-03-09 14:40:22.234 [WARN ] [re.storage.json.internal.JsonStorage] - Json storage file at '/var/lib/openhab/jsondb/backup/1678110143340--org.openhab.core.thing.Thing.json' is empty - ignoring corrupt file.
2023-03-09 14:40:22.236 [WARN ] [re.storage.json.internal.JsonStorage] - Json storage file at '/var/lib/openhab/jsondb/backup/1678110141664--org.openhab.core.thing.Thing.json' is empty - ignoring corrupt file.

So you moved back org.openhab.core.thing.Thing.json while openhab already was running …?
That may be the reason why your file is corrupted and things disappeared then.
I don’t know what the OH does when it starts and does not find a thing json file. I would expect it to create an empty one but what happens in case it is overwritten with one containing the previous collection of things. It may be overwritten again with content from runtime and then your things are gone.

That’s not causing the error. The error exists before I have done that.

I saw that the JSON file was not complete. So there is information missing. With the description of a thing, the file breaks off. Among various backup files, I then took one from half a year ago and replaced this file. Accordingly, I have significantly fewer Things. At least that’s what I thought. In reality, even reading in the backup file does not work. I stopped openHAB and deleted the cache before replacing the file. Ergo, there must be another error somewhere.

Probably your files are on ZRAM and if there is no storage left such corruption can occur.

If you upgrade to OH 3.3 or newer there is a fix to prevent such corruption: