Problems with Mariadb JDBC persistance after OH4 upgrade

After the upgrade to Openhab 4.0.3 I noticed some problems with the MariaDB JDBC persistance plugin.

First I noticed that after installing the MariaDB JDBC plugin the title in the UI changed to JDBC persistence (SQLite). But the URL says that it is the mariadb plugin:

This was very confusing, but the even worse problem is that a lot more items are now being persisted in the mariadb database than I configured. I only configured 4 items, but for some reason I now have over 100 items in the database. And the list is still growing, so I guess that every updated items gets created in the database.

Here is my jdbc.persist file:

Strategies {}

Items {
    ST_Entrance_Serial_Door_Reader, ST_Cellar_Serial_Door_Reader : strategy = everyUpdate

    NUM_MotionEventsDaily, NUM_MotionEventsHourly : strategy = everyUpdate, restoreOnStartup

Has something regarding the configuration changed or what could cause this problem?

I can’t answer for the SQLite in the title.

In OH 3 a default strategy was implemented by all the persistence addons. This default applies when there isn’t a .persist file or, in OH 4.0+, a managed config created through MainUI. Usually that strategy is to persist every Item on everyChange with restoreOnStartup (rrd4j of course is slightly different).

Do you see this file being loaded when OH starts or you change the file? You should see something like “loading model jdbc.persist”.

If on OH 4, if you navigate to Settings → Other: Persistence → JDBC → Gear Icon → Persistence Configuration is the contents of your jdbc.persist file represented there?

I can see the line “Loading model ‘jdbc.persist’” if I change the file, but it does not show up when restarting Openhab.

I can also not see the settings of the file in the UI until I change something in the persist file.

I guess that this is the cause of the problem. None of my persist files are showing up on startup. Any idea how to fix this?

No ideas. I’m not even certain where to file the issue but would probably start with OH core.

I played today for the first time with jdbc persistence and am seeing the exact same problems … openHAB 4.0.2

Probably related:

@sihui I just noticed that my sitemap file has the same problem. Then I found this thread in the forum: Bug since OH4: Why are the default.sitemap and *.things files not loaded on startup? (empty sitemap list) - #8 by somy

The fix from wezzix with the two commands to clean up the cache worked for me. Maybe the openhab-cli clean-cache command does not work anymore? I’m sure I’ve cleaned the cache with this command after the update.

I just found out that clearing the cache is only a temporary solution. When OH is restarted the next time the files are not loaded again. So this can not be the solution.

I also tried if I can reproduce this in the development environment, but the problem does not exist there. I guess this is because the development environment does not have this cache enabled.

I uninstalled everything to have a working openHAB again and hope the github issue gets fixed some time.

@sihui Are you also using Openhabian? I’ve just tried to reproduce this problem on a different system with the Docker image of Openhab, but the problem does not occur there. Maybe this is related to Openhabian.

No. Manual install on Proxmox.

Maybe I found a solution for the problem. I remembered that there is a limit how much files can be watched under linux. I increased this limit as described here:

Since then all my files are loaded when I restart Openhab. Maybe this helps you too.

Hmm, just checked my log but all persist files are already loaded at startup, just need to restart OH today

2023-09-29 21:43:43.416 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model ‘influxdb.persist’
2023-09-29 21:43:43.499 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model ‘jdbc.persist’
2023-09-29 21:43:43.540 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model ‘logging.persist’
2023-09-29 21:43:43.548 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model ‘rrd4j.persist’
2023-09-29 21:43:43.575 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model ‘mapdb.persist’

Thus I still have no idea why more files are persisted than configured in file :-/

Same mix up of sqlite/mariadb here. Debian/apt install/openHAB 4.0.4.

Try 1#

  • No jbdbc.persist and no addons.cfg
  • binding mariadb loaded, entered credentials. In this second the binding overview switched to sqlite/loaded and mariadb was invisible
  • cache/tmp emptied various times. No success
  • When I remove sqlite, mariadb appears again (unloaded). I load it and it disappears again
  • The sqlite binding (star icon) contains the mariadb settings like db/username/password/port
  • the connection itself from openhab to mariadb is working, items are stored
  • “Settings → Other: Persistence → JDBC → Gear Icon → Persistence Configuration”. The gear icon doesn´t exist. I click on enable one and only JDBC or not → no gear icon

Try #2

  • cache/tmp emptied various times
  • usage of jbdbc.persist and addons.cfg
  • Same perception like in try #1

Looks like there is a mix up between sqlite/mariadb?