MariaDB: double entries with EveryUpdate strategy

I’m running OH 4.1 on Linux, as JDBC database, I use MariaDB.

For some reason, I get double entries in the database when using ‘EveryUpdate’ as a strategy for that specific Item. The Item is not in a Group policy.

the Item with the double entry is the one starting with Netatmo_regen, jdbc.persist looks like this:

Strategies {
	default = everyChange
 }

Items {

* : strategy = everyChange, restoreOnStartup
WaterDeltaNew2 : strategy = everyChange
JachtlaanSlaapkamer_Temperature : strategy = everyUpdate
Netatmo_regen_RainDelta : strategy = everyUpdate

}

double entries:

In the JDBC settings, I also see a MySQL and a MariaDB entry, both configs are exactly the same and point towards MariaDB.

JDBC is my persistant service.

Any ideas?

It’s doing exactly what you told it to.

First of all it’s important to realize that strategies are additive. So all your items will have everyChange and restoreOnStartup. In addition to those, Netamo_regen_RainDelt will have everyUpdate.

Since a change is an update the value gets saved once for the change and again for the update.

hi @rlkoshak thanks, I tried already to delete the default strategy, worked but no other item was updated. The double entries in the database are all after a change in valure, so the strategy does what I told it to do. But how do I tell the default is on everyChange, and the exepctions should update on everyUpdate.

Well, of course not. When you remove the default you have to explicitly list each Item you want to save to persistence.

You don’t because there is no concept of “exceptions”. Like I said above, the strategies are additive. * applies to all Items whether they are listed elsewhere in the persistence config or not.

So your choices are:

  1. Make * the minimum strategy possible (restoreOnStartup) and then you need to list each of your Items separately with the strategy desired. You can use Design Pattern: Group Based Persistence to make that a little less work. Though if your minimum strategy is only restoreOnStartup you should probably just exclude the * line entirely and add restoreOnStartup to the other lines because restoreOnStartup doesn’t make sense if you don’t also have a strategy to save that Item too.

  2. Make default strategy be everyUpdate which will capture the changes too without the double entries. You’ll have to live with the fact that some of your Items will save more data than necessary (not every Item will receive updates when there is no change so it probably won’t be a lot of entries).

  3. Live with the double entries.

Thanks again, Rich.
I picked option 2, since managing a few hundred Items sems to be complex. And the additional storage isn’t that big a deal. Works like a charme, and I learned a thing or two on persistance :wink: