Mapdb and mysql - mqsql works, mapdb does not

Hi folks,

Since I started I have used mysql persistence. It works and works well. I want to use mapdb now for restoreOnStartup to see if I can make restarting of OH a bit quicker as some of my items have a lot of history and also runs on an RPi

I have mapdb installed. It does not persist anything unless I call .persist(“mapdb”) in a rule.
I have logging set to debug and can only see it doing stuff when I call .persist(“mapdb”). It does not persist on change

mysql.persist


// persistence strategies have a name and a definition and are referred to in the "Items" section
Strategies {
	// if no strategy is specified for an item entry below, the default list will be used
	everyMinute		: "0 * * * * ?"
	every5Minutes 	: "0 */5 * * * ?"
   	everyHour   	: "0 0 * * * ?"
   	everyDay    	: "0 0 0 * * ?"
   	default = everyChange
}

/* 
 * Each line in this section defines for which item(s) which strategy(ies) should be applied.
 * You can list single items, use "*" for all items or "groupitem*" for all members of a group
 * item (excl. the group item itself).
 */

Items {
	g_persist_change* 	: strategy = everyChange//, restoreOnStartup
	g_persist_minute* 	: strategy = everyMinute//, restoreOnStartup
    g_persist_5minute* 	: strategy = every5Minutes//, restoreOnStartup
    g_persist_hour* 	: strategy = everyHour
    g_persist_day* 		: strategy = everyDay
	gScenePersist*		: strategy = everyChange//, restoreOnStartup
}


mapdb.persist

// persistence strategies have a name and a definition and are referred to in the "Items" section
Strategies {
	// if no strategy is specified for an item entry below, the default list will be used
	// everyMinute	: "0 * * * * ?"
	// every5Minutes : "0 */5 * * * ?"
   	// everyHour   : "0 0 * * * ?"
   	//everyDayMapDB    : "0 0 0 * * ?"
   	default = everyChange
}




Items {
    // persist all items once a day and on every change and restore them from the db at startup
    g_persist_restore* : strategy = everyChange, restoreOnStartup
}

Items

Number JJKKUU "JJKKJJ"   (g_persist_restore)
Number JJKKII   "KKLL"   (g_persist_restore)

adons.cfg

# A comma-separated list of persistence services to install (e.g. "rrd4j,jpa")
persistence = mysql,mapdb

LogFile

2019-08-06 11:32:57.246 [DEBUG] [org.openhab.persistence.mapdb       ] - BundleEvent STARTING - org.openhab.persistence.mapdb
2019-08-06 11:32:57.255 [DEBUG] [b.internal.MapDBPersistenceActivator] - MapDB persistence bundle has been started.
2019-08-06 11:32:57.263 [DEBUG] [org.openhab.persistence.mapdb       ] - ServiceEvent REGISTERED - {org.openhab.core.persistence.PersistenceService}={service.id=524, service.bundleid=273, service.scope=bundle, component.name=org.openhab.persistence.mapdb, component.id=353} - org.openhab.persistence.mapdb
2019-08-06 11:32:57.281 [DEBUG] [pdb.internal.MapDBPersistenceService] - mapdb persistence service is being activated
2019-08-06 11:32:57.776 [DEBUG] [pdb.internal.MapDBPersistenceService] - Scheduled Commit-Job with interval 5sec.
2019-08-06 11:32:57.779 [DEBUG] [pdb.internal.MapDBPersistenceService] - mapdb persistence service is now activated
2019-08-06 11:32:57.787 [DEBUG] [org.openhab.persistence.mapdb       ] - BundleEvent STARTED - org.openhab.persistence.mapdb

The only thing I am not sure of is the default persistence setting in PaperUI. I have that set to mysql.
I am running this all on a RPi with SD card so do not want to write a lot to it so weary of setting that.
When I called .persist() without specifying the service it stored it in mysql. Why would that be considering there was no mysql attached to it.

Anything obvious as to why my items are not persisting with mapdb?

TIA

C

Can’t see anything funny in mapdb.persist
The only unusual thing is no time based strategies defined at all - I have them defined in my working setup, event though they are unused.

Persistence services are 1.x legacy, and not so clever about picking up dynamic changes. Be sure to reboot OH since last change.

Because you made it the default service. This won’t be the problem with mapdb.

I restart the service after each change to be sure.
Regarding the time, I did have the daily one included as well. Same outcome.

Odd thing though, in frustration I gave up and moved onto something else. I commented out the contents of the mapdb file and moved on. Just came back now to see the logs peppered with

2019-08-06 14:42:46.479 [DEBUG] [pdb.internal.MapDBPersistenceService] - Stored 'UtilityElectricPulseTick' with state '1' in mapdb database
2019-08-06 14:42:59.604 [DEBUG] [pdb.internal.MapDBPersistenceService] - store called for UtilityElectricPulseTick
2019-08-06 14:42:59.607 [DEBUG] [pdb.internal.MapDBPersistenceService] - Stored 'UtilityElectricPulseTick' with state '1' in mapdb database
2019-08-06 14:43:10.547 [WARN ] [l.script.controls.tablet.state.rules] - Brighten Screen - Setting brightness to 100.
2019-08-06 14:43:13.162 [DEBUG] [pdb.internal.MapDBPersistenceService] - store called for UtilityElectricPulseTick
2019-08-06 14:43:13.180 [DEBUG] [pdb.internal.MapDBPersistenceService] - Stored 'UtilityElectricPulseTick' with state '1' in mapdb database
2019-08-06 14:43:31.372 [DEBUG] [pdb.internal.MapDBPersistenceService] - store called for UtilityElectricPulseTick
2019-08-06 14:43:31.393 [DEBUG] [pdb.internal.MapDBPersistenceService] - Stored 'UtilityElectricPulseTick' with state '1' in mapdb database
2019-08-06 14:43:49.553 [DEBUG] [pdb.internal.MapDBPersistenceService] - store called for UtilityElectricPulseTick
2019-08-06 14:43:49.557 [DEBUG] [pdb.internal.MapDBPersistenceService] - Stored 'UtilityElectricPulseTick' with state '1' in mapdb database
2019-08-06 14:44:07.429 [DEBUG] [pdb.internal.MapDBPersistenceService] - store called for UtilityElectricPulseTick
2019-08-06 14:44:07.443 [DEBUG] [pdb.internal.MapDBPersistenceService] - Stored 'UtilityElectricPulseTick' with state '1' in mapdb database
2019-08-06 14:44:25.384 [DEBUG] [pdb.internal.MapDBPersistenceService] - store called for UtilityElectricPulseTick
2019-08-06 14:44:25.390 [DEBUG] [pdb.internal.MapDBPersistenceService] - Stored 'UtilityElectricPulseTick' with state '1' in mapdb database
2019-08-06 14:44:43.236 [DEBUG] [pdb.internal.MapDBPersistenceService] - store called for UtilityElectricPulseTick
2019-08-06 14:44:43.247 [DEBUG] [pdb.internal.MapDBPersistenceService] - Stored 'UtilityElectricPulseTick' with state '1' in mapdb database
2019-08-06 14:45:02.755 [DEBUG] [pdb.internal.MapDBPersistenceService] - store called for UtilityElectricPulseTick
2019-08-06 14:45:02.790 [DEBUG] [pdb.internal.MapDBPersistenceService] - Stored 'UtilityElectricPulseTick' with state '1' in mapdb database

So it does work, just not when I want to it.
The log also shows why I need to get it working properly. That PulseTick item toggles a lot and I don’t need it restored.

Well, we know mapdb works in general for everyone else.
Curious why it now selects that Pick Item, but not clear what “comment out” really means nor what happens with a presumably blank canvas.

Do you ever see Loading model 'mapdb.persist’ in openhab.log?

The file can be picky about what editor you use, to do with newlines I think, but I guess whatever you do works with mysql okay.

yup, with each restart.

2019-08-06 15:59:23.105 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'mapdb.persist'

Ok… so, I had a double espresso

I had not made a group called g_persist_restore…

Well, that is a few hours of my life I will never get back… :frowning:

/Thanks

Ah. :confounded: