Mapdb not working in OH3

Not sure when this started, but after several restarts following OH3 implementation I’ve had StartPersist items not update.

My mapdb.persist file is configured as:

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

A sample item is:

String House_Mode "House Mode [%s]" <heating> (StartPersist)

The logs contain the following entry:

2020-10-22 09:27:53.326 [WARN ] [org.jline                           ] - Failed to save history
java.nio.file.AccessDeniedException: /var/lib/openhab2
	at sun.nio.fs.UnixException.translateToIOException( ~[?:?]
	at sun.nio.fs.UnixException.rethrowAsIOException( ~[?:?]
	at sun.nio.fs.UnixException.rethrowAsIOException( ~[?:?]
	at sun.nio.fs.UnixFileSystemProvider.createDirectory( ~[?:?]
	at java.nio.file.Files.createDirectory( ~[?:?]
	at java.nio.file.Files.createAndCheckIsDirectory( ~[?:?]
	at java.nio.file.Files.createDirectories( ~[?:?]
	at org.jline.reader.impl.history.DefaultHistory.internalWrite( ~[bundleFile:?]
	at ~[bundleFile:?]
	at org.jline.reader.impl.history.DefaultHistory.add( [bundleFile:?]
	at org.jline.reader.impl.LineReaderImpl.finishBuffer( [bundleFile:?]
	at org.jline.reader.impl.LineReaderImpl.readLine( [bundleFile:?]
	at [bundleFile:4.2.7]
	at [bundleFile:4.2.7]
	at [?:?]

Which is bothersome as the path /var/lib/openhab2 of course no longer exists. Any thoughts on a fix?

I just installed MapDB an it seems to be working, see this DEBUG output.

2020-10-22 16:54:51.469 [DEBUG] [pdb.internal.MapDbPersistenceService] - store called for OpusPi_Cpu_SystemUptime
2020-10-22 16:54:51.476 [DEBUG] [pdb.internal.MapDbPersistenceService] - Stored 'OpusPi_Cpu_SystemUptime' with state '14640.3' in MapDB database
2020-10-22 16:54:51.554 [DEBUG] [pdb.internal.MapDbPersistenceService] - store called for CPUTemperature
2020-10-22 16:54:51.574 [DEBUG] [pdb.internal.MapDbPersistenceService] - Stored 'CPUTemperature' with state '41.2' in MapDB database

On which snapshot # are you? I’m on #1978 Did this eror occur after installing mapDB or after a restart?

Your mapdb.persist files does NOT persist a Group, it is set for ALL items!

1 Like

This may apply too.

OH 3.0.0~S1979-1, newly updated this AM.

I was having some issues with this after migrating to OH3 but didn’t test it thoroughly, so I cannot say when it really happened. I had mapdb installed previously and it moved over with my migration, so I had not changed any configuration up to this point.

Yes, when I was looking through this I saw that persistence was set for all! I did try to set the item selection in mapdb.persist to the group StartPersist only, but that did not work either

Thanks @Bruce_Osborne. The issue looks similar, but I have a feeling not quite the same. My log entry
" Failed to save history java.nio.file.AccessDeniedException: /var/lib/openhab2 "
Suggests there is a path hard coded that is a relic of OH2?

No that issue doesn’t apply here.
It was commented because it has been difficult to find the real cause and at first we thought it was MapDB.
You can look at for details

Have you migrated from OH 2.4 or ealier version to OH 3.0? Or are you using a new (empty) installation of OH3?

I run into the same error by migration from 2.4 to 2.5.8.
My only solution was to delete mapdb related files from \userdata\persistence\mapdb and start with an empty mapdb.

For me it looks like there is a difference between OH 2.4 and OH 2.5x (and maybe 3.x) about handling mapdb entries. I think in my mapdb was a no longer allowed entry causes the error.

Thanks, @HomeAutomation. I did try this as well, deleting all of the files in this folder and restarting OpenHAB but I continue to see the same issue.

I migrated from 2.5.9 up to 3.0, it is not a new, empty installation. I’m getting a different log entry that that indicated in; I’m not sure I have the same problem that they are tracking but I’ll be patient and see how that issue resolves.

So it has been over a month since this problem has surfaced. I’m now running 3.0.0 S2039 (after running M3) and in all of this time, mapdb continues to not function.
I’ve uninstalled the binding, deleted it’s storage files…several times in fact. And it continues to do nothing. Is there something else I can try???

If you are seeing this problem although the binding got reinstalled and all old persisted files got deleted I’d file an issue on github. However, do you still see this message
Failed to save history java.nio.file.AccessDeniedException: /var/lib/openhab2, or is made just doing nothing?

I again ran a debug,

log:set DEBUG org.openhab.persistence.mapdb

And NOTHING (!) shows up in the log files beyond an INFO entry:

[port.EventAdminConfigurationNotifier] - Sending Event Admin notification (configuration successful) to org/ops4j/pax/logging/Configuration

Which seems to indicate only that I’ve changed my log:set criteria.

Failed to save history java.nio.file.AccessDeniedException: /var/lib/openhab2, or is made just doing nothing?

My logs no longer contain this note, so perhaps something was cleaned up from the mapdb installation files.

It just seems that mapdb is not functioning at all, but its log files are recreated everytime I delete them, so it is clearly doing something.
There are several github issues surrounding mapdb out there already. I’ll continue to look to see if one of them is most relevant to what seems to be happening in my case. I’ve not opened a github issue before, that would be new territory!