(OH3) default persistence

In ordert o do some special tests concerning the migration of persistence files I need to get the default persistence back again (more precise the automatically started rrd4j persistence when no persistence is configured).
However I can’t get it started. I tried it with no serviceinstalled, *.cfg and no *.persist file restarting the openhab service.

Take notes please and post it back. I’m in the same boat I think as I’m about to write the Persistence page for getting started and I need to get back to the default state too. I’m probably going to just spin up a new docker container to explore.

However, I did see another thread where someone deleted their .persist files and it’s still saving data, presumably based on the default profile.

1 Like

Found it. There was a PR awhile back that allows each persistence add-on to define it’s own default strategy. The new doc for rrd4j states

every Item on every state change and at least once a minute. Additionally, it restores the last stored value at system startup.

Theoretically if there is no .persist file it should revert back to this. But I wonder if it’s like the .cfg files and a version of the .persist file gets copied into useradata somewhere and didn’t get deleted when you deleted the .persist file.

Interesting. Does it mean we don’t need mapdb any more ?

rrd4j won’t store String Items and other non-number type Items so if you need to restoreOnStartup those you still need MapDB (or one of the other DBs).

right, it crossed my mind the moment I switched off my PC :laughing:

Now wondering what’ll happen to string items, does rrd4j restore string items to some default value (if so which one ?)
Does mapdb take precedence when we have rrd4j and mapdb (or other) both doing RestoreOnStartup ? or is it startup order coincidence ?
What if it’s a numeric item but they are not the same in mapdb vs rrd4j because of some error on storing them ?

@Kai could you please clarify or do you have a link to a proper description?
We should mention that in the breaking changes, too.

Tried a restart after a clean-cache, nothing persisted. Stilling searching/thinking…

Clearing the cache won’t necessarily change the .persist file if that gets copied over to userdata somewhere. I did a search though and I can’t find anything. I’m starting to wonder if this is a bug. It seems that if you’ve ever had an rrd4j.persist file you have to always have one as there’s no way to get back to the default. If that’s expected behavior we need to document it. If not it feels like a bug.

I think the sentence in the docs is a little misleading and it works like it always has. Instead of “every Item” it should probably read “every supported Item (number type Items, binary type Items (Switch, Contact), and DateTime Items)…”.

From what I see with only cursory experiments String type Items don’t get restored from rrdj4. Bu there are a lot more experiments I need to perform to verify that.

I bet it works the same as it always has. But I admit, I’ve no idea how it’s always worked in that case. I too am curious what happens.

To add to the questions:

  • What’s the default strategy for MapDB?
  • Did we lose the readme for MapDB in the next.openhab.org/docs or has it never been there? In fact a lot of the persistence add-ons are missing their readmes.

No, it does not handle String items.

Does mapdb take precedence when we have rrd4j and mapdb (or other) both doing RestoreOnStartup

There is no precedence, when using multiple persistence services you should configure them both in a way that you do not use both of them for the same item for restoreOnStartup.

Theoretically if there is no .persist file it should revert back to this.

Yes, that’s how it should be. the *.persist files are NOT copied anywhere to userdata, so once you delete them, this configuration should be gone and the default kicks in.

What’s the default strategy for MapDB?

Looks like restore and everyChange.

Did we lose the readme for MapDB in the next.openhab.org/docs or has it never been there?

Looks as if we had one, but it was lost when the mapdb service was rewritten for ESH - it was actually the only persistence service that was 2.x compatible (and not 1.x). Anybody willing to port the README.md to the new location? I am not using mapdb and thus cannot really say much about its usage and features…

1 Like

That’s a challenge now that rrd4j by default does RestoreOnStartup and applies to all items but strings, isn’t it ?
Least thing I would need to do is to deploy a rrd4j.persist to exclude RestoreOnStartup and use mapdb for all. But in a default OH3 deployment, rrd4j will compete with mapdb and even you don’t know the outcome of that competition.
In other words, everybody who wants to use persistence with RestoreOnStartup must do.

So shouldn’t we rather remove RestoreOnStartup from rrd4j’s default strategy ?

1 Like

Stupid question, is an INSTALLED persistence service or a explicitly set default service (i.e. rrd4j) needed?

Obviously rrd4j needed to be installed, after that all suported items get persisted.

Not at all. Users who want to deal with persistence can do it exactly the same way as for OH2 - define persistence config files for the services they have chosen.

The default rrd strategy is meant for newbies that do NOT want to deal with persistence in the first place. I absolutely agree that missing support for a couple of item types like String, Call, Color and Location is not nice, but it is the best we can do with rrd4j.

Did some further testing concerning the use of rrd4j.
When trying to use a .rrd file build before OH3 users need to:

  • create an item with the same name as before
  • drop in that file in the /var/lib/openhab/persistence/rrd4j folder

rrd4j will obviously use the setup as stored in the .rrd file, I tested it with a file that used the default setup of OH2 and before. I would think that such would work with any .rrd file, in other words for an existing .rrd file a custom rrd4j.cfg file is not needed. IMHO such should be a point for the migration docs!

Additionally I need to take back the request for a “Breaking Change” note concerning rrd4j. I WAS in the false believe that rrd4j would need a rrd4j.cfg file to store data in a custom way.


1 Like

Don"t tell my English teacher :wink:

well it’s not wrong, is it. It’s braking you.

Does this mean rrd4j is mandatory?
In my setup items are not persisted and I don’t know yet why.

I would like to use mapDB (restoreOnStartup) and influxdb.
So, I uninstalled rrd4j, set influxdb to default and put my OH2.5x influx.persist and mapdb.persist into /etc/openhab/persistence.

So, is there anything wrong with my approach?

Sounds good to me. What I am worried about is mapDB with restoreOnStartUp. After reading several threads which stated problems about that I can’t say if it is or better should be working.

From my observations it’s working.
rrd4j is not installed and mapDB is configured to RestoreOnStartup.
During startup the items seem to be restored properly.

1 Like

In addition to String, it appears to me that RRD4j persistence does not store DateTime. Either that, or it just chose not to restore all of my DateTime items when I restarted OH just now.