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: https://howchoo.com/node/node-increase-file-watcher-system-limit

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?

Issue solved in current version openHAB 4.1.0

dear community

I’m struggling with a fresh install of OpenHAB 4.1.2-1 and mariadb 11.3.2-1 on archlinux (via yay) and the JDBC connection somehow not being established correctly. I followed the howtos (had it working for years), /etc/openhab4/services/jdbc.cfg setup correctly I believe, mariadb created correctly, user access working. still I get the following errors when starting up OpenHAB

2024-04-21 09:25:36.530 [DEBUG] [jdbc.internal.JdbcPersistenceService] - JDBC::activate: persistence service activated
2024-04-21 09:25:36.530 [DEBUG] [jdbc.internal.JdbcPersistenceService] - JDBC::updateConfig
2024-04-21 09:25:36.531 [DEBUG] [ence.jdbc.internal.JdbcConfiguration] - JDBC::JdbcConfiguration
2024-04-21 09:25:36.531 [DEBUG] [ence.jdbc.internal.JdbcConfiguration] - JDBC::updateConfig: configuration size = 18
2024-04-21 09:25:36.539 [DEBUG] [ence.jdbc.internal.JdbcConfiguration] - JDBC::updateConfig: user=openhab
2024-04-21 09:25:36.539 [DEBUG] [ence.jdbc.internal.JdbcConfiguration] - JDBC::updateConfig: password exists? true
2024-04-21 09:25:36.540 [INFO ] [g.discovery.internal.PersistentInbox] - Added new thing ‘openweathermap:weather-and-forecast:api:local’ to inbox.
2024-04-21 09:25:36.540 [DEBUG] [ence.jdbc.internal.JdbcConfiguration] - JDBC::updateConfig: url=jdbc:mariadb://localhost:3306/openhab_db
2024-04-21 09:25:36.541 [DEBUG] [ence.jdbc.internal.JdbcConfiguration] - JDBC::updateConfig: found serviceName = ‘mariadb’
2024-04-21 09:25:36.541 [DEBUG] [ence.jdbc.internal.JdbcConfiguration] - JDBC::updateConfig: Init Data Access Object Class: ‘org.openhab.persistence.jdbc.internal.db.JdbcMariadbDAO’
2024-04-21 09:25:36.550 [DEBUG] [istence.jdbc.internal.db.JdbcBaseDAO] - JDBC::initSqlTypes: Initialize the type array
2024-04-21 09:25:36.551 [DEBUG] [ence.jdbc.internal.db.JdbcMariadbDAO] - JDBC::initSqlTypes: Initialize the type array
2024-04-21 09:25:36.551 [INFO ] [etatmo.internal.servlet.GrantServlet] - Registered Netatmo servlet at ‘/netatmo/connect/6308ef7879ce10dddd060ccc’
2024-04-21 09:25:36.551 [DEBUG] [ence.jdbc.internal.db.JdbcMariadbDAO] - JDBC::initSqlQueries: ‘JdbcMariadbDAO’
2024-04-21 09:25:36.551 [DEBUG] [ence.jdbc.internal.JdbcConfiguration] - JDBC::updateConfig: dBDAO ClassName=org.openhab.persistence.jdbc.internal.db.JdbcMariadbDAO
2024-04-21 09:25:36.554 [DEBUG] [ence.jdbc.internal.JdbcConfiguration] - JDBC::updateConfig: errReconnectThreshold=3
2024-04-21 09:25:36.554 [DEBUG] [ence.jdbc.internal.JdbcConfiguration] - JDBC::updateConfig: itemsManageTable=Items
2024-04-21 09:25:36.556 [DEBUG] [ence.jdbc.internal.JdbcConfiguration] - JDBC::updateConfig: tableNamePrefix=Item
2024-04-21 09:25:36.556 [DEBUG] [ence.jdbc.internal.JdbcConfiguration] - JDBC::updateConfig: tableUseRealItemNames=true
2024-04-21 09:25:36.556 [DEBUG] [ence.jdbc.internal.JdbcConfiguration] - JDBC::updateConfig: tableIdDigitCount=0
2024-04-21 09:25:36.556 [DEBUG] [ence.jdbc.internal.JdbcConfiguration] - JDBC::updateConfig: enableLogTime false
2024-04-21 09:25:36.558 [DEBUG] [ence.jdbc.internal.JdbcConfiguration] - JDBC::updateConfig: load JDBC-driverClass was successful: ‘org.mariadb.jdbc.Driver’
2024-04-21 09:25:36.559 [DEBUG] [ence.jdbc.internal.JdbcConfiguration] - JDBC::updateConfig: configuration complete. service=jdbc
2024-04-21 09:25:36.560 [DEBUG] [persistence.jdbc.internal.JdbcMapper] - JDBC::pingDB
2024-04-21 09:25:36.561 [DEBUG] [persistence.jdbc.internal.JdbcMapper] - JDBC::openConnection isDriverAvailable: true
2024-04-21 09:25:36.561 [INFO ] [persistence.jdbc.internal.JdbcMapper] - JDBC::openConnection: Driver is available::Yank setupDataSource
2024-04-21 09:25:36.674 [DEBUG] [ence.jdbc.internal.JdbcConfiguration] - JDBC::setDbConnected true
2024-04-21 09:25:36.674 [DEBUG] [ence.jdbc.internal.db.JdbcMariadbDAO] - JDBC::initAfterFirstDbConnection: Initializing step, after db is connected.
2024-04-21 09:25:36.695 [DEBUG] [tence.jdbc.internal.utils.DbMetaData] - dbMajorVersion = ‘11’
2024-04-21 09:25:36.699 [DEBUG] [tence.jdbc.internal.utils.DbMetaData] - dbMinorVersion = ‘3’
2024-04-21 09:25:36.699 [DEBUG] [tence.jdbc.internal.utils.DbMetaData] - driverMajorVersion = ‘3’
2024-04-21 09:25:36.699 [DEBUG] [tence.jdbc.internal.utils.DbMetaData] - driverMinorVersion = ‘0’
2024-04-21 09:25:36.699 [DEBUG] [tence.jdbc.internal.utils.DbMetaData] - dbProductName = ‘MariaDB’
2024-04-21 09:25:36.700 [DEBUG] [tence.jdbc.internal.utils.DbMetaData] - dbProductVersion = ‘11.3.2-MariaDB’
2024-04-21 09:25:36.700 [DEBUG] [persistence.jdbc.internal.JdbcMapper] - JDBC::pingDB asking db for name as absolutely first db action, after connection is established.
2024-04-21 09:25:36.730 [DEBUG] [persistence.jdbc.internal.JdbcMapper] - JDBC::checkDBAcessability, first try connection: true
2024-04-21 09:25:36.731 [DEBUG] [jdbc.internal.JdbcPersistenceService] - JDBC::getName: returning name ‘jdbc’ for queryable persistence service.
2024-04-21 09:25:36.731 [DEBUG] [jdbc.internal.JdbcPersistenceService] - JDBC::updateConfig: configuration complete for service=jdbc.
2024-04-21 09:25:36.731 [DEBUG] [jdbc.internal.JdbcPersistenceService] - bundle org.openhab.persistence.jdbc:4.1.2 (271)[org.openhab.persistence.jdbc.internal.JdbcPersistenceService(368)] : invoked activate: activate
2024-04-21 09:25:36.731 [DEBUG] [jdbc.internal.JdbcPersistenceService] - bundle org.openhab.persistence.jdbc:4.1.2 (271)[org.openhab.persistence.jdbc.internal.JdbcPersistenceService(368)] : Set implementation object for component
2024-04-21 09:25:36.731 [DEBUG] [jdbc.internal.JdbcPersistenceService] - bundle org.openhab.persistence.jdbc:4.1.2 (271)[org.openhab.persistence.jdbc.internal.JdbcPersistenceService(368)] : Changed state from satisfied to active
2024-04-21 09:25:36.732 [DEBUG] [jdbc.internal.JdbcPersistenceService] - JDBC::getName: returning name ‘jdbc’ for queryable persistence service.
2024-04-21 09:25:36.743 [DEBUG] [persistence.jdbc.internal.JdbcMapper] - JDBC::pingDB
2024-04-21 09:25:36.743 [DEBUG] [persistence.jdbc.internal.JdbcMapper] - JDBC::openConnection isDriverAvailable: true
2024-04-21 09:25:36.746 [DEBUG] [persistence.jdbc.internal.JdbcMapper] - JDBC::checkDBAcessability, first try connection: true
2024-04-21 09:25:36.746 [WARN ] [jdbc.internal.JdbcPersistenceService] - JDBC::query: database not connected, query aborted for item ‘localHourlyForecast15Temperature’
2024-04-21 09:25:36.748 [DEBUG] [persistence.jdbc.internal.JdbcMapper] - JDBC::pingDB
2024-04-21 09:25:36.748 [DEBUG] [persistence.jdbc.internal.JdbcMapper] - JDBC::openConnection isDriverAvailable: true
2024-04-21 09:25:36.759 [DEBUG] [persistence.jdbc.internal.JdbcMapper] - JDBC::checkDBAcessability, first try connection: true
2024-04-21 09:25:36.760 [WARN ] [jdbc.internal.JdbcPersistenceService] - JDBC::query: database not connected, query aborted for item ‘Netatmo_Sleeping_BatteryVP’
2024-04-21 09:25:36.763 [DEBUG] [persistence.jdbc.internal.JdbcMapper] - JDBC::pingDB
2024-04-21 09:25:36.763 [DEBUG] [persistence.jdbc.internal.JdbcMapper] - JDBC::openConnection isDriverAvailable: true
2024-04-21 09:25:36.764 [DEBUG] [persistence.jdbc.internal.JdbcMapper] - JDBC::checkDBAcessability, first try connection: true
2024-04-21 09:25:36.764 [WARN ] [jdbc.internal.JdbcPersistenceService] - JDBC::query: database not connected, query aborted for item ‘Netatmo_Indoor_Location’
2024-04-21 09:25:36.767 [DEBUG] [persistence.jdbc.internal.JdbcMapper] - JDBC::pingDB

…and then openhab.log keeps showing the following for every item that is being persisted

2024-04-21 09:25:43.740 [DEBUG] [persistence.jdbc.internal.JdbcMapper] - JDBC::pingDB
2024-04-21 09:25:43.741 [DEBUG] [persistence.jdbc.internal.JdbcMapper] - JDBC::openConnection isDriverAvailable: true
2024-04-21 09:25:43.742 [DEBUG] [persistence.jdbc.internal.JdbcMapper] - JDBC::checkDBAcessability, first try connection: true
2024-04-21 09:25:43.742 [WARN ] [jdbc.internal.JdbcPersistenceService] - JDBC::store: No connection to database. Cannot persist state ‘OFF’ for item ’

does someone have a clue what this could be? I’m desperate

thank you for any help