Can't get RestoreOnStartUp to work

High, I’m trying to get RestoreOnStartUp using MapDB to work.
I’m using OpenHAB2, MapDB is installed as well as RRRD4J. RRD4J is working as expected.
In MapDB.persist I have:

Items {
* : strategy = everyChange, restoreOnStartup
}

I have set to log:list to include

org.openhab.persistence.mapdb | DEBUG

but the only [Debug] entries in the log are:

20:04:36.837 [DEBUG] [org.openhab.persistence.mapdb ] - BundleEvent STARTING - org.openhab.persistence.mapdb
20:04:36.844 [DEBUG] [b.internal.MapDBPersistenceActivator] - MapDB persistence bundle has been started.
20:04:36.875 [DEBUG] [org.openhab.persistence.mapdb ] - ServiceEvent REGISTERED - {org.openhab.core.persistence.PersistenceService}={service.pid=org.openhab.mapdb, commitinterval=5, component.name=org.openhab.persistence.mapdb, component.id=171, commitsamestate=false, service.id=307, service.bundleid=198, service.scope=bundle} - org.openhab.persistence.mapdb
20:04:36.899 [DEBUG] [pdb.internal.MapDBPersistenceService] - mapdb persistence service activated
20:04:37.502 [DEBUG] [pdb.internal.MapDBPersistenceService] - Scheduled Commit-Job with interval 5sec.
20:04:37.526 [DEBUG] [org.openhab.persistence.mapdb ] - BundleEvent STARTED - org.openhab.persistence.mapdb

I did several changes to items.

When restarting OpenHAB no data is restored.

It looks to me as if MapDB isn’t storing any data.

Check your userdata/persistence folder. You should see a mapdb folder in there. There should be at least one mapdb file in there and it should have a non-zero size.

Verify all of these are the case. If not it means your MapDB is not saving any data. If the mapdb folder doesn’t exist you may need to create it. This is something I ran into when setting it up and I’ve submitted an issue over it.

I do have a mapdb-folders folders under /var/lib/openhab2 and /var/lib/openhab2/persistence . Both with 3 non zero files. Which folder is really needed and which file should get updates?

[Edit]
I’m feeling sorry, because it’s always you who is answering my questions.

1 Like

They are both needed. The “main” mapdb folder is for the item/things internal
DB of OH. The subfolder in openhab2/persistence is the right one to watch.

The persistence one is the one that is relevant to restoreOnStartup. Does it have a timestamp from today?

In both folder is a file named “storag-apdb.t”. Both have a date of yesterday, probably the time when OH was started last.
So MapDB migth be storing the states, but I think they don’t get restored. How would I get Debug mesages for the restoring?

in each folder should be three files:

storage.mapdb
storage.mapdb.p
storage.mapdb.t

The files in /userdata/mapdb should have a timestamp from when the last config through PaperUI (or Habmin) has been changed.
The files in /userdata/persistence/mapdb should have a timestamp from the last item change (push a switch or whatever).

Edit: I don’t use apt-get at the moment, so your folder locations may be different …

Yes, the name is “storage.mapdb*” :blush:
I do see only the file “storag-apdb.t” getting an update in the date/time whenever restarting OpenHAB. That is true for the files in “openhab2/persistence/mapdb” as well as in “openhab2/mapdb”.
The size of all 3 files in each of the folders do not change.

After digging deeper, I realized number items are getting restored, however the string items (which I was looking at) are not. In my understanding mapdb would store strings as well.

Maybe OH is mixing up the two installed persistence services? You wrote that you are also using RRD4J and RRD4J ONLY stores number items. Is this a coincidence that number items get restored?

The rrd4j-restriction to numer items is understood by me.
How could I test if OH is mixing this up? rrd4j is working as expected.

I would give it a try and completely disable rrd4j and only use mapdb. Define mapdb as standard in PaperUI, make a reboot (just to be sure…) and then “play” a little bit with the system to get some value/item changes. Then take a look if the mapdb files will change.

Furthermore please take a look at the example for the restoreonstartup persistence
configuration (scroll completely down to the bottom of the link):

http://docs.openhab.org/features/items.html

The example looks a little different compared to yours…

I do not see any difference besides the missing declaration of a default strategy. I’m not using it, so it isn’t needed.
Tried to remove rrd4j persistence using PaperUI, didn’t work:angry:

What log:set command is need to get such log-entries:

2016-08-09 21:26:11.958 [DEBUG] [.p.m.i.MapDBPersistenceService] - store called for mapdbTest
2016-08-09 21:26:11.961 [DEBUG] [.p.m.i.MapDBPersistenceService] - Stored ‘mapdbTest’ with state ‘ON’ in mapdb database

Copied from another thread!

log:set debug org.openhab.persistence.mapdb
should do it.
Edit:

http://docs.openhab.org/administration/logging.html#create-log-entries-in-own-rules

2nd Edit: I just tried the above command and yes, it’s working as expected.
To set it back to info level you need:
log:set info org.openhab.persistence.mapdb

Thanks for that input.
First I had no entries, then I did insert a default strategy (is suggested by @jaydee73). I was WRONG, after changing the .persist file I got log-entries immidiatly!!

Now I do see entries for my string item being logged, but after a restart this string item remains NULL??

[Edit] Never mind, after a second restart, the stroed string value is used!

Good news!