Clearing cache results on loss of admin user and sitemap

After migrating from OpenHAB 4.3.x to 5.0.2 (OpenSUSE Leap 15.5), if I stop the OpenHAB service (systemctl stop openhab) and then run openhab-cli clean-cache (as root) or manually remove the files via rm -rf /var/lib/openhab/cache /var/lib/openhab/tmp, on restart (systemctl start openhab) I experience this:

  • On navigating via a web browser to http://openhab:8080/ it will ask me to create an admin account (see attachment)
  • The Android client reports that no sitemaps can be found (and this is confirmed via the web browser, once creating a new admin account and logging in)
  • Other settings (Things, model, …) seem to be preserved.

Any ideas?

I’ve no ideas because OH stores the user accounts in /var/lib/openhab/jsondb/users.json. It’s not stored in cache nor tmp.

Sitemaps are stored either in /etc/openhab/sitemaps if manually created or in /var/lib/openhab/jsondb/uicomponents_system_sitemap.json.

These files exist alongside where Things and Items are stored and the jsondb file is untouched by clearing the cache. Something else must be going on. Do you have any strange mount points, symbolic links, non-standard installation configurations, etc?

Indeed. And users.json was were it was expected to be and appeared to have the correct details, as far as I could tell.

Same here. The relevant file is there, just it doesn’t get picked up.

If I re-create the admin user, most of the other configuration is still there. The UI will ask me to go through the set-up process (provide timezone, location, etc.) but the data is already there so whether one follows or skips the set up dialogues does not seem to make any difference. The one piece of data that is not picked up by the system is the sitemap (of which I only have one) even though, as you say, the relevant file is there and seems correct.

I ended up restoring the 4.3.7 backup onto another computer and then copied the site map definition from the UI (code tab) and pasted onto the new install, which works fine.

There were also other errors, such as many console commands (e.g., log:tail, log:set) not being available. I managed to solve those with some AI help, which involved a selective, manual restore and use of /usr/share/openhab/runtime/bin/upgradetool.jar.

Sorry I can’t offer any useful cues. I’m not familiar with OpenHAB’s internal architecture and hadn’t come across anything like this before. Just sharing in the hope that someone else has seen, or will see in the future, something similar.

Just to add: should anybody feel like trying clearing the cache on their system in an attempt at reproducing the issue, I would strongly suggest to take a full backup first:

systemctl stop openhab &&
openhab-cli backup --full "openhab-$(date -u +%Y%m%d%H%M%S).zip" &&
openhab-cli clean-cache;

systemctl start openhab

In my case, restoring the full backup has brought back full functionality after the breakage caused by clearing the cache.

As far as I know no one else has either.

Did you try to just restore your config from 4.3 over to a new 5.0 install instead of doing an in place upgrade? A bunch of steps get skipped when you try to do that and indeed you must run the upgradeTool manually in that case. But even if that were the case, a cache clearing shouldn’t cause these problems.

Note, clearing the cache is part of the upgrade process. You cannot upgrade to a new version of OH without it.

Yes, I did all these:

  • Upgrade to 5.0.2, without restore → :frowning:
  • Upgrade to 5.0.2, with restore → :frowning:
  • Install 5.0.2 anew, restore, run upgradeTool → :smiling_face:
  • Install 5.0.2 anew, restore, run upgradeTool, clear cache → I haven’t tried. I might give it a go later (on a spare computer) and see if that break things. I guess we all agree that it shouldn’t, right?

Correct. It shouldn’t. tmp is just temporary files. cache is where add-ons get installed to. Removing the cache causes the reinstallation of the add-ons, which is what you want when upgrading and in cases where there are problems related to add-ons being installed or initialized.

Clearing the cache does not impact any settings.

Note, the difference between a normal backup and a full backup is the cache and tmp are included in the full backup.