[SOLVED] Mapdb not working

I’m on openhabian.

I have the following .persist file:

Strategies {
    default = everyChange, restoreOnStartup

Items {
    Driveway_Detect, Motion_Count: strategy = everyChange, restoreOnStartup

The following .items file:

Switch Driveway_Detect "Driveway Motion Detect Disable"
Number Motion_Count "Motion Count: [%d]"
String Garage_test "Garage [%s]" <garage>

I see no indication of the items being persisted.

There are files in /srv/openhab2-userdata/persistence/mapdb. In particular, storage.mapdb.t changes.

But, when I reboot the value of the Motion_Count item is NULL.

I tried to activate DEBUG in /srv/openhab2-userdata/etc/org.ops4j.pax.logging.cfg.
Setting log4j2.logger.openhab.level = DEBUG got lots of DEBUG lines in the log but none had anything indicating Mapdb.


Items {
    * : strategy = everyChange, restoreOnStartup

but maybe it’s simple as the missing space before the ‘:’.

You would need to enable proper debugging, org.openhab.persistence.mapdb that would be I believe.
Use Karaf console (log:set debug org.openhab…) instead of editing that file.

Space, no difference
*, no difference
log:set DEBUG org.openhab.persistence.mapdb, no DEBUG lines in the log viewer


Hmm, sounds like a more fundamental problem of your installation because at least the debug command IS creating proper output on my system. Did you ever try lower case “debug” ? Restarted the system ? I don’t mean to reboot, you never should be using that command as it’ll not properly shut down OH.

Well, I have rebooted a couple times…since that is the point of persistence for me, to persist the values in case of a power outage.

On the other hand I also have not learned the proper shutdown of openhabian. I see in the console app there is a stop. Does oh not respond to normal linux shutdown notices?

But, I did try both upper and lower case debug.

Ugh, well. You should go for a reliable server solution (to include a UPS, backup etc) but that’s another story.
In openhabian, OH runs as a systemd service, so the proper way to shut it down is service openhab2 stop or (I think …) systemctl stop openhab2.service. The console command might work as well.
In most Unices the reboot command ignores running services and does NOT send shutdown notices, or it doesn’t wait long enough for them to shutdown.

On your original problem … try shutting down OH, then remove mapdb dir contents and restart. Check for rw permissions on that dir, too, there should be 3 files not just 1.
See if mapdb debugging throws any errors on startup to give a hint as to why it does not work.
Other than that I’ve no idea, other than to purge and reinstall the OH software (just the packages, not all of openHABian. And make sure you have proper config backup/restore in place before doing that).

The plan is to have UPS. Backups are a must on any system. As for the Pi as a reliable server, I’ve read many comments in many forums about how easy they corrupt. But, that has not been my experience. I have several running 24/7/365 and have had no issues. I one particular application, there is one as the internet gateway for a subnet, another using RFID for physical access control, and another for power control of a amp and signal processor rack. All have been running for a few years and only one has an overlay meant to avoid SD card corruption. Through power outages, power switches without shutdown, etc. and I’ve not logged into them since they were put in service. I’ve had one running my PLEX server, for two years, again 24/7, no issues.

I typically use “shutdown” with -h or -P which I believe does a SIGTERM. Or, “shutdown -r” which I think does a SIGTERM as well. But, I’ll have to confirm that.

I just did a “service openhab2 stop” and noted this in the log:

2018-08-23 07:00:39.729 [DEBUG] [org.openhab.persistence.mapdb       ] - BundleEvent STOPPING - org.openhab.persistence.mapdb

2018-08-23 07:00:39.738 [DEBUG] [org.openhab.persistence.mapdb       ] - ServiceEvent UNREGISTERING - {org.openhab.core.persistence.PersistenceService}={service.id=379, service.bundleid=218, service.scope=bundle, commitinterval=60, service.pid=org.openhab.mapdb, component.name=org.openhab.persistence.mapdb, component.id=255} - org.openhab.persistence.mapdb

2018-08-23 07:00:39.741 [DEBUG] [pdb.internal.MapDBPersistenceService] - mapdb persistence service deactivated

2018-08-23 07:00:39.760 [DEBUG] [pdb.internal.MapDBPersistenceService] - Found 1 MapDB-Jobs to delete from DefaultScheduler (keys=[MapDB_SchedulerGroup.Commit_Transaction])

2018-08-23 07:00:39.764 [DEBUG] [b.internal.MapDBPersistenceActivator] - MapDB persistence bundle has been stopped.

2018-08-23 07:00:39.766 [DEBUG] [org.openhab.persistence.mapdb       ] - BundleEvent STOPPED - org.openhab.persistence.mapdb

So, apparently mapdb was active.
I cleared the cache then rebooted.

On startup the only mention of mapdb in the log:

2018-08-23 07:58:22.956 [thome.event.ExtensionEvent] - Extension 'persistence-mapdb' has been installed.

Um…not sure what that entails.

How does one purge and reinstall just packages? Can I do that from openhabian-config?

What is a “proper config back/restore” and how does one put it in place? (I’ve read some of the discussions on the forum about backup strategies, etc. but never seen a "do it however you want but make sure you have copies of , etc.) Is it as simple as “sudo openhab-cli backup bckup-180823” and copy the resulting .zip file to a safe place?

See this post including the Amanda Readme this links to. You can install Amanda from the openHABian menu.

No need for that. Just service openhab2 start next time.

No I don’t think so. Use apt-get purge openhab2 openhab-addons in shell, then re-install either using shell or openhabian menu.

I was referring to openhab-cli backup/restore shell command. Read up on it.

Did you select default service?

Well, in fact I had selected the default service.

But, as I read that link, I noted the .persist file name was suppose to match the add-on name.

I had mistakenly named it in the manor of .rules and .items, etc.

Once I changed the name from driveway.persist to mapdb.persist things started being preserved.

So, I guess…operator error. :flushed: