This is very unexpected. Mapdb only keeps one entry for every item, and replaces it when the item gets updated. I can’t see how it can grow indefinitely. It should stop growing once all items have been changed at least once.
What system are you running on? Could there be an SD card corruption in play?
How many items do you have? Do you frequently create items with new names? Old items may keep hanging around in there.
You can always stop OH, delete the database and start again. The only inconvenience will be item states will not be restored at the start, but only on the first update. Mapdb will grow the, until all items have been persisted (and a bit more, as the previous state will also be persisted on the next change), but that should be it.
My system is a Proxmox LXC container and in my system are currently 805 items. It’s a very stable system where very little items are created. I actually can’t remember when i did it the last time.
The system base is Debian.
Previously my system was dockerized and I noticed the same behavior, but not to such an extent. Caches were already cleared and mapdb deleted, but it happens again.
To give you a figure. When I restored my system from a backup and deleted mapdb on last Thursday. It grew like this
Time
MapDB size
remark
16.4. at 20:33
0
17.4. at 0:17
75 MiB
(~4 hours later)
18.4. at 0:17
850 MiB
19.4. at 0:17
1.66 GiB
This is insane. Any idea how i can track the cause?
ls -alh /var/lib/openhab/persistence/mapdb/
total 1.8G
drwxr-xr-x 2 openhab openhab 4.0K Mar 26 11:46 .
drwxr-xr-x 5 openhab openhab 4.0K Mar 26 11:46 ..
-rwxr-xr-x 1 openhab openhab 32 Feb 22 22:31 Readme.txt
-rw-r--r-- 1 openhab openhab 33K Jan 26 02:01 storage.mapdb
-rw-r--r-- 1 openhab openhab 2.0M Jan 26 02:01 storage.mapdb.p
-rw-r--r-- 1 openhab openhab 2.0G Apr 19 10:04 storage.mapdb.t
It’s interesting that your storage.mapdb.p file is much larger than mine. And vice versa my storage.mapdb.t file is huge compared to yours. May be this is a route worth looking at.
Transaction Log Bloat: The .t file is a “Write Ahead Log” (transaction log). MapDB appends every single change to this file first. In a healthy state, these changes are merged into the main .p file and the .t file is cleared.
High-Frequency Items: If you have “noisy” items (e.g., power meters, signal strength sensors, or rapidly updating temperature probes), they generate thousands of writes. MapDB 1.0 (used in openHAB) often struggles to clear the log as fast as it grows when the volume is this high.
The “Commit” Failure: Once the .t file reaches a certain size (often 2GB or 4GB depending on the JVM/system), the internal memory-mapping can fail or become extremely slow, preventing the “commit” process from ever successfully shrinking the file.
My Solution
Get rid of the “*” for items and create a group for hosting the persisted items that make sense to be restored on startup. As I have about 800 Items with lots of them being statuse
Listed all Items in the console with openhab:items list and asked the AI which Items are good candidates for a restore group
Checked the resulting candidates and had the AI create a script to add these items to my restore group
This way I reduced the number of items to be restored to around 30.