Could not create rrd4j database file OH 4

Running OH 4.2.1 on a Pi 4B with 4GB RAM.
Technical Information:

runtimeInfo:
  version: 4.2.1
  buildString: Release Build
locale: en-US
systemInfo:
  configFolder: /etc/openhab
  userdataFolder: /var/lib/openhab
  logFolder: /var/log/openhab
  javaVersion: 17.0.12
  javaVendor: Debian
  osName: Linux
  osVersion: 6.6.31+rpt-rpi-v8
  osArchitecture: aarch64
  availableProcessors: 4
  freeMemory: 339648040
  totalMemory: 805306368
  uptime: 79033
  startLevel: 70
addons:
  - automation-jsscripting
  - automation-jsscriptingnashorn
  - binding-androidtv
  - binding-astro
  - binding-denonmarantz
  - binding-exec
  - binding-generacmobilelink
  - binding-gpstracker
  - binding-icalendar
  - binding-icloud
  - binding-ipcamera
  - binding-irobot
  - binding-logreader
  - binding-mail
  - binding-mqtt
  - binding-network
  - binding-networkupstools
  - binding-ntp
  - binding-openweathermap
  - binding-remoteopenhab
  - binding-roku
  - binding-tplinksmarthome
  - binding-zwave
  - misc-homekit
  - misc-openhabcloud
  - persistence-rrd4j
  - transformation-jinja
  - transformation-jsonpath
  - transformation-map
  - transformation-regex
  - ui-basic
  - ui-habpanel
clientInfo:
  device:
    ios: false
    android: false
    androidChrome: false
    desktop: true
    iphone: false
    ipod: false
    ipad: false
    edge: false
    ie: false
    firefox: false
    macos: false
    windows: true
    cordova: false
    phonegap: false
    electron: false
    nwjs: false
    webView: false
    webview: false
    standalone: false
    os: windows
    pixelRatio: 1.5
    prefersColorScheme: light
  isSecureContext: false
  locationbarVisible: true
  menubarVisible: true
  navigator:
    cookieEnabled: true
    deviceMemory: N/A
    hardwareConcurrency: 8
    language: en-US
    languages:
      - en-US
      - en
    onLine: true
    platform: Win32
  screen:
    width: 1707
    height: 1067
    colorDepth: 24
  support:
    touch: false
    pointerEvents: true
    observer: true
    passiveListener: true
    gestures: false
    intersectionObserver: true
  themeOptions:
    dark: light
    filled: true
    pageTransitionAnimation: default
    bars: light
    homeNavbar: default
    homeBackground: default
    expandableCardAnimation: default
    blocklyRenderer: null
  userAgent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML,
    like Gecko) Chrome/128.0.0.0 Safari/537.36
timestamp: 2024-09-12T19:11:40.671Z

I am getting many of these errors (different items, but the same error.

2024-09-11 16:49:01.690 [ERROR] [d4j.internal.RRD4jPersistenceService] - Could not create rrd4j database file '/var/lib/openhab/persistence/rrd4j/gGarlandLights.rrd': Invalid file header. File [/var/lib/openhab/persistence/rrd4j/gGarlandLights.rrd] is not a RRD4J RRD file
2024-09-11 16:49:01.701 [ERROR] [d4j.internal.RRD4jPersistenceService] - Could not create rrd4j database file '/var/lib/openhab/persistence/rrd4j/gThermostatsLowerTemperatureSettings.rrd': Invalid file header. File [/var/lib/openhab/persistence/rrd4j/gThermostatsLowerTemperatureSettings.rrd] is not a RRD4J RRD file
2024-09-11 16:49:01.710 [ERROR] [d4j.internal.RRD4jPersistenceService] - Could not create rrd4j database file '/var/lib/openhab/persistence/rrd4j/somecomfort1863934Upstairs_Temperature.rrd': Invalid file header. File [/var/lib/openhab/persistence/rrd4j/somecomfort1863934Upstairs_Temperature.rrd] is not a RRD4J RRD file
2024-09-11 16:49:01.715 [ERROR] [d4j.internal.RRD4jPersistenceService] - Could not create rrd4j database file '/var/lib/openhab/persistence/rrd4j/somecomfort1864745Master_Humidity.rrd': Invalid file header. File [/var/lib/openhab/persistence/rrd4j/somecomfort1864745Master_Humidity.rrd] is not a RRD4J RRD file```

Searching the forum I found many references to this error, such as:
https://community.openhab.org/t/could-not-create-rrd4j-database-file-error-in-oh3/113025/47
https://community.openhab.org/c/add-ons/persistence/16
https://community.openhab.org/t/could-not-create-rrd4j-database-file-file-is-not-a-rrd4j-rrd-file/149613

My non expert takeaway from these threads is that it is a ZRAM memory problem.  I have seen suggestions to increase the memory allocation to this, but don't want to randomly change numbers I don't really understand.


```yaml
openhabian@oh-s:/etc/default $ zramctl --output-all
NAME       DISKSIZE   DATA COMPR ALGORITHM STREAMS ZERO-PAGES TOTAL MEM-LIMIT MEM-USED MIGRATED MOUNTPOINT
/dev/zram0       1G     4K   87B lzo-rle         4          0   12K      300M      12K       0B [SWAP]
/dev/zram1     750M 699.5M 15.6M zstd            4     137843   18M      300M      18M       0B /opt/zram/zram1
/dev/zram2       1G 105.4M 19.6M zstd            4       1776 23.2M      600M    23.2M       0B /opt/zram/zram2
openhabian@oh-s:/etc/default $ 

It would probably be helpful to prune items, as I’m sure I have some legacy items that I no longer use that are encumbering the process. But I would appreciate suggestions of how to change the memory settings.

Thanks

Each Item requires at most 738k of storage in rrd4j. One or two Items is unlikely to make any sort of meaningful difference.

If in fact you are running out of space on the zram partition then increasing the size of that zram partition will solve the probnlem. But if not, it won’t change anything. There is not enough information here to say if that is what’s happening or not.

Run df -h. Do either of the zram file systems show as being full?.

Thanks @rlkoshak


openhabian@oh-s:~ $ df -h
Filesystem      Size  Used Avail Use% Mounted on
udev            1.9G     0  1.9G   0% /dev
tmpfs           385M  2.7M  382M   1% /run
/dev/mmcblk0p2   15G  6.7G  6.8G  50% /
tmpfs           1.9G     0  1.9G   0% /dev/shm
tmpfs           5.0M   12K  5.0M   1% /run/lock
/dev/mmcblk0p1  510M   64M  447M  13% /boot/firmware
/dev/zram1      721M  683M     0 100% /opt/zram/zram1
overlay1        721M  683M     0 100% /var/lib/openhab/persistence
/dev/zram2      974M   63M  844M   7% /opt/zram/zram2
overlay2        974M   63M  844M   7% /var/log
tmpfs           385M     0  385M   0% /run/user/1000
openhabian@oh-s:~ $ 

I’m not sure how to read this, but it looks like the first is 100%

Yes, that’s clear that you’ve run out of space on the persistence zram partition.

Removing some Items could help. Changing your persistence strategy to only save those Items you really need could help. Or you can bump up the size of zram1. Just remember that zram lives in ram so the bigger you make the partition the less RAM everything else in the system has to work with. You need to find a happy balance.

Do you have any other folders in /var/lib/openhab/persistence besides rrd4j? MapDB and SQLite will both save their files there too.

Yes, but they don’t have much in them.


openhabian@oh-s:/var/lib/openhab/persistence $ ls -lstotal 88
 4 drwxr-xr-x 2 openhab openhab  4096 Sep 11 15:07 db4o
 4 drwxr-xr-x 2 openhab openhab  4096 Sep 11 15:07 mapdb
80 drwxr-xr-x 2 openhab openhab 81920 Sep 11 15:07 rrd4j
openhabian@oh-s:/var/lib/openhab/persistence $


openhabian@oh-s:/var/lib/openhab/peopenhabian@oh-s:/var/lib/openhab/persistence $ free -m
               total        used        free      shared  buff/cache   available
Mem:            3841        1851         131           2        1937        1990
openhabian@oh-s:/var/lib/openhab/peopenhabian@oh-s:/var/lib/openhab/persistence $

It looks to my untrained eye that I could spare some RAM.

How do I adjust it?

Edit /etc/ztab and reboot.

Use some command like find /var/lib/openhab/persistence/ -type f -mtime +15 |xargs ls -l {}\;
to find outdated files. Replace ls -l by rm to delete.

Your mapdb and db4o folders look really small. And if your rrd4j folder only has 81920 bytes in it that’s way less than the 750m allocated to the file system. It’s also suspicious that mapdb and db4o are the same size. I’d expect db4o to be much larger than mapdb given that mapdb only sames one record per Item.

For comparison I have 383 Items and am using the standard strategies for mapdb and rrd4j. My usage is 24M for mapdb and 169M for rrd4j. That comes to rougly half a MB per Item. So I should be able to store up to 1500 Items (assuming the same ratio of number Items and non-number Items) in 750M.

How many Items do you have?

Run that command with -h so we can see the actual units of the folder’s sizes being shown.

Note however that when I run ls =lstotal -hd on my Ubuntu system, I get 20k for rrd4j and 4k for mapdb, so make sure you run the command so it goes into the folders too.

󰕈 argus  rich  …/openhab/userdata/persistence   main ✘!?   07:21 
 ls -lstotal -h mapdb
total 24M
4.0K -rw-rw-rw- 1 openhab   16 Sep 13 07:21 storage.mapdb.t
 36K -rw-rw-rw- 1 openhab  33K Sep 13 07:21 storage.mapdb
 24M -rw-rw-rw- 1 openhab  24M Sep 13 07:21 storage.mapdb.p
4.0K drwxrwxrwx 4 openhab 4.0K May  3  2023 ../
4.0K drwxrwxrwx 2 openhab 4.0K May  3  2023 ./

󰕈 argus  rich  …/openhab/userdata/persistence   main ✘!?   07:21 
 ls -lstotal -hd mapdb
4.0K drwxrwxrwx 2 openhab 4.0K May  3  2023 mapdb/

Thank you for the response

Here is my current ztab:

# swap  alg             mem_limit       disk_size       swap_priority   page-cluster    swappiness
swap    lzo-rle         300M            1G              75              0               150

# dir   alg             mem_limit       disk_size       target_dir                      bind_dir
dir     zstd            300M            750M            /var/lib/openhab/persistence    /persistence.bind

# log   alg             mem_limit       disk_size       target_dir              bind_dir                oldlog_dir
log     zstd            600M            1G              /var/log                /log.bind

From reading the comments in the this file, it would seem like increasing mem_limit to 350 and disk_size to 850 for the 2nd entry might be a good first step. Does that sound reasonable?

openhabian@oh-s:/etc/default $ find /var/lib/openhab/persistence/ -type f -mtime +15 | xargs ls -l
total 104
-rw-r--r-- 1 root root  219 Apr 19  2023 avahi-daemon
-rw-r--r-- 1 root root  846 Dec 10  2023 bluetooth
-rw------- 1 root root  384 Dec  3  2023 cacerts
-rw-r--r-- 1 root root  276 Jul  3 19:06 console-setup
-rw-r--r-- 1 root root  910 Jun  7 09:10 cpu_governor
-rw-r--r-- 1 root root  955 Jul 17  2022 cron
-rw-r--r-- 1 root root  297 Sep 16  2023 dbus
-rw-r--r-- 1 root root 1014 Sep 11 15:24 exim4
-rw-r--r-- 1 root root   84 Mar  5  2012 fake-hwclock
-rw-r--r-- 1 root root   81 Mar 28 04:52 hwclock
-rw-r--r-- 1 root root  150 Jul  3 19:06 keyboard
-rw-r--r-- 1 root root  113 Sep 11 15:21 locale
-rw-r--r-- 1 root root 1032 Sep 14  2021 networking
-rw-r--r-- 1 root root  793 Jan 11  2023 nfs-common
-rw-r--r-- 1 root root 1756 Apr 19 15:46 nss
-rw-r--r-- 1 root root 2403 Sep 11 16:13 openhab
-rw-r--r-- 1 root root  300 Jul 25  2023 raspberrypi-sys-mods
-rw-r--r-- 1 root root  548 Apr 24 11:51 raspi-firmware
-rw-r--r-- 1 root root  356 Jul 27  2022 rpcbind
-rw-r--r-- 1 root root   34 Jun 12 04:04 rpi-eeprom-update
-rw-r--r-- 1 root root 2062 Dec 18  2022 rsync
-rw-r--r-- 1 root root  133 Dec 19  2023 ssh
-rw-r--r-- 1 root root  284 Sep 11 15:23 sysstat
-r--r--r-- 1 root root  287 Aug 22 11:41 tailscaled
-rw-r--r-- 1 root root  548 Aug 30  2016 triggerhappy
-rw-r--r-- 1 root root 1117 Jul  3 19:06 useradd

(It didn’t like the {}\ on the end, so I removed it and it generated this list.)
I assume these are files that were swapped but later orphaned and are just sitting there taking up space. This is a fresh installation - I downloaded openhabian to a new SD card using the Raspberry Pi Imager this week), so I’m surprised there are old files there, but then again I don’t know much about how this works.

The results don’t make sense. Those are not openHAB files at all, those are files in /etc/default.

Try running the command from the /var/lib/openhab/persistence folder.

1,668

That is the directory I was in. I thought the file parameter in the find command would redirect it to the persistence folder, but obviously it didn’t.

openhabian@oh-s:/var/lib/openhab/persistence $ find rrd4j/ -type f -mtime +15 | xargs ls -l -h
total 88K
drwxr-xr-x 2 openhab openhab 4.0K Sep 11 15:07 db4o
drwxr-xr-x 2 openhab openhab 4.0K Sep 11 15:07 mapdb
drwxr-xr-x 2 openhab openhab  80K Sep 11 15:07 rrd4j

That doesn’t seem big enough to be causing a memory problem. Perhaps there is another cause for the

2024-09-13 10:21:01.642 [ERROR] [d4j.internal.RRD4jPersistenceService] - Could not create rrd4j database file '/var/lib/openhab/persistence/rrd4j/Weather_ForecastDay3_Gustspeed.rrd': Invalid file header. File [/var/lib/openhab/persistence/rrd4j/Weather_ForecastDay3_Gustspeed.rrd] is not a RRD4J RRD file
2024-09-13 10:21:01.666 [ERROR] [d4j.internal.RRD4jPersistenceService] - Could not create rrd4j database file '/var/lib/openhab/persistence/rrd4j/Weather_ForecastDay4_Uvindex.rrd': Invalid file header. File [/var/lib/openhab/persistence/rrd4j/Weather_ForecastDay4_Uvindex.rrd] is not a RRD4J RRD file
2024-09-13 10:21:01.668 [ERROR] [d4j.internal.RRD4jPersistenceService] - Could not create rrd4j database file '/var/lib/openhab/persistence/rrd4j/Weather_ForecastDay4_Windspeed.rrd': Invalid file header. File [/var/lib/openhab/persistence/rrd4j/Weather_ForecastDay4_Windspeed.rrd] is not a RRD4J RRD file
2024-09-13 10:21:01.680 [ERROR] [d4j.internal.RRD4jPersistenceService] - Could not create rrd4j database file '/var/lib/openhab/persistence/rrd4j/Weather_ForecastDay5_Rain.rrd': Invalid file header. File [/var/lib/openhab/persistence/rrd4j/Weather_ForecastDay5_Rain.rrd] is not a RRD4J RRD file
2024-09-13 10:21:01.701 [ERROR] [d4j.internal.RRD4jPersistenceService] - Could not create rrd4j database file '/var/lib/openhab/persistence/rrd4j/Weather_ForecastHours03_Apparenttemperature.rrd': Invalid file header. File [/var/lib/openhab/persistence/rrd4j/Weather_ForecastHours03_Apparenttemperature.rrd] is not a RRD4J RRD file
2024-09-13 10:21:01.704 [ERROR] [d4j.internal.RRD4jPersistenceService] - Could not create rrd4j database file '/var/lib/openhab/persistence/rrd4j/Weather_ForecastHours03_Gustspeed.rrd': Invalid file header. File [/var/lib/openhab/persistence/rrd4j/Weather_ForecastHours03_Gustspeed.rrd] is not a RRD4J RRD file
2024-09-13 10:21:01.706 [ERROR] [d4j.internal.RRD4jPersistenceService] - Could not create rrd4j database file '/var/lib/openhab/persistence/rrd4j/Weather_ForecastHours03_Precipprobability.rrd': Invalid file header. File [/var/lib/openhab/persistence/rrd4j/Weather_ForecastHours03_Precipprobability.rrd] is not a RRD4J RRD file
2024-09-13 10:21:01.729 [ERROR] [d4j.internal.RRD4jPersistenceService] - Could not create rrd4j database file '/var/lib/openhab/persistence/rrd4j/Weather_ForecastHours06_Apparenttemperature.rrd': Invalid file header. File [/var/lib/openhab/persistence/rrd4j/Weather_ForecastHours06_Apparenttemperature.rrd] is not a RRD4J RRD file
2024-09-13 10:21:01.732 [ERROR] [d4j.internal.RRD4jPersistenceService] - Could not create rrd4j database file '/var/lib/openhab/persistence/rrd4j/Weather_ForecastHours06_Dewpoint.rrd': Invalid file header. File [/var/lib/openhab/persistence/rrd4j/Weather_ForecastHours06_Dewpoint.rrd] is not a RRD4J RRD file
2024-09-13 10:21:01.736 [ERROR] [d4j.internal.RRD4jPersistenceService] - Could not create rrd4j database file '/var/lib/openhab/persistence/rrd4j/Weather_ForecastHours06_Precipprobability.rrd': Invalid file header. File [/var/lib/openhab/persistence/rrd4j/Weather_ForecastHours06_Precipprobability.rrd] is not a RRD4J RRD file
2024-09-13 10:21:01.751 [ERROR] [d4j.internal.RRD4jPersistenceService] - Could not create rrd4j database file '/var/lib/openhab/persistence/rrd4j/Weather_ForecastHours06_Winddirection.rrd': Invalid file header. File [/var/lib/openhab/persistence/rrd4j/Weather_ForecastHours06_Winddirection.rrd] is not a RRD4J RRD file
2024-09-13 10:21:01.764 [ERROR] [d4j.internal.RRD4jPersistenceService] - Could not create rrd4j database file '/var/lib/openhab/persistence/rrd4j/Weather_ForecastHours08_Cloudiness.rrd': Invalid file header. File [/var/lib/openhab/persistence/rrd4j/Weather_ForecastHours08_Cloudiness.rrd] is not a RRD4J RRD file
2024-09-13 10:21:01.778 [ERROR] [d4j.internal.RRD4jPersistenceService] - Could not create rrd4j database file '/var/lib/openhab/persistence/rrd4j/Weather_ForecastHours09_Temperature.rrd': Invalid file header. File [/var/lib/openhab/persistence/rrd4j/Weather_ForecastHours09_Temperature.rrd] is not a RRD4J RRD file
2024-09-13 10:21:01.794 [ERROR] [d4j.internal.RRD4jPersistenceService] - Could not create rrd4j database file '/var/lib/openhab/persistence/rrd4j/Weather_ForecastHours11_Pressure.rrd': Invalid file header. File [/var/lib/openhab/persistence/rrd4j/Weather_ForecastHours11_Pressure.rrd] is not a RRD4J RRD file
2024-09-13 10:21:01.806 [ERROR] [d4j.internal.RRD4jPersistenceService] - Could not create rrd4j database file '/var/lib/openhab/persistence/rrd4j/Weather_ForecastHours12_Windspeed.rrd': Invalid file header. File [/var/lib/openhab/persistence/rrd4j/Weather_ForecastHours12_Windspeed.rrd] is not a RRD4J RRD file
2024-09-13 10:21:01.807 [ERROR] [d4j.internal.RRD4jPersistenceService] - Could not create rrd4j database file '/var/lib/openhab/persistence/rrd4j/Weather_ForecastToday_Apparentday.rrd': Invalid file header. File [/var/lib/openhab/persistence/rrd4j/Weather_ForecastToday_Apparentday.rrd] is not a RRD4J RRD file
2024-09-13 10:21:01.831 [ERROR] [d4j.internal.RRD4jPersistenceService] - Could not create rrd4j database file '/var/lib/openhab/persistence/rrd4j/Weather_ForecastTomorrow_Maxtemperature.rrd': Invalid file header. File [/var/lib/openhab/persistence/rrd4j/Weather_ForecastTomorrow_Maxtemperature.rrd] is not a RRD4J RRD file
2024-09-13 10:21:01.833 [ERROR] [d4j.internal.RRD4jPersistenceService] - Could not create rrd4j database file '/var/lib/openhab/persistence/rrd4j/Weather_ForecastTomorrow_Nighttemperature.rrd': Invalid file header. File [/var/lib/openhab/persistence/rrd4j/Weather_ForecastTomorrow_Nighttemperature.rrd] is not a RRD4J RRD file
2024-09-13 10:21:01.835 [ERROR] [d4j.internal.RRD4jPersistenceService] - Could not create rrd4j database file '/var/lib/openhab/persistence/rrd4j/Weather_ForecastTomorrow_Pressure.rrd': Invalid file header. File [/var/lib/openhab/persistence/rrd4j/Weather_ForecastTomorrow_Pressure.rrd] is not a RRD4J RRD file
2024-09-13 10:21:01.854 [ERROR] [d4j.internal.RRD4jPersistenceService] - Could not create rrd4j database file '/var/lib/openhab/persistence/rrd4j/ZWavePowerPlugNode004025800200707217_Electricmetervolts.rrd': Invalid file header. File [/var/lib/openhab/persistence/rrd4j/ZWavePowerPlugNode004025800200707217_Electricmetervolts.rrd] is not a RRD4J RRD file
2024-09-13 10:21:01.864 [ERROR] [d4j.internal.RRD4jPersistenceService] - Could not create rrd4j database file '/var/lib/openhab/persistence/rrd4j/gGarlandLights.rrd': Invalid file header. File [/var/lib/openhab/persistence/rrd4j/gGarlandLights.rrd] is not a RRD4J RRD file
2024-09-13 10:21:01.876 [ERROR] [d4j.internal.RRD4jPersistenceService] - Could not create rrd4j database file '/var/lib/openhab/persistence/rrd4j/gThermostatsLowerTemperatureSettings.rrd': Invalid file header. File [/var/lib/openhab/persistence/rrd4j/gThermostatsLowerTemperatureSettings.rrd] is not a RRD4J RRD file
2024-09-13 10:21:01.885 [ERROR] [d4j.internal.RRD4jPersistenceService] - Could not create rrd4j database file '/var/lib/openhab/persistence/rrd4j/somecomfort1863934Upstairs_Temperature.rrd': Invalid file header. File [/var/lib/openhab/persistence/rrd4j/somecomfort1863934Upstairs_Temperature.rrd] is not a RRD4J RRD file
2024-09-13 10:21:01.890 [ERROR] [d4j.internal.RRD4jPersistenceService] - Could not create rrd4j database file '/var/lib/openhab/persistence/rrd4j/somecomfort1864745Master_Humidity.rrd': Invalid file header. File [/var/lib/openhab/persistence/rrd4j/somecomfort1864745Master_Humidity.rrd] is not a RRD4J RRD file

that I’m seeing.

I thought so too which is why the command is kind of weird. But I haven’t had a chance to test it out and based on the result I know it would work from the persistence folder itself. :person_shrugging:

What’s weird is the find command that @mstormi posted works fine for me. I should note that your command also works fine for me. You should be seeing only files in rrd4j with your command but you are only seeing the folders in persistence, which should even be happening because -type f should ignore folders in the first place.

Are you perhaps running some non-standard shell?

Something very weird is going on.

I tried to run these find commands on my main OH server. In the off chance that something is up with openhabian I tried it remotely on my other OH instance I run at my dad’s house. There I’m seeing the same thing as you.

󰐿 huginn  rich  ~   10:16 
 find /var/lib/openhab/persistence/ -type f -mtime +15 | xargs ls -lh
total 26M
drwxrwxr-x 3 atuin atuin 4.0K Feb 15  2024 '['\'''
-rw-r--r-- 1 rich  rich   26M Mar 19 11:18  journalbeat-7.15.2-amd64.deb
drwx------ 3 rich  rich  4.0K Feb 13  2024  snap
-rw-r--r-- 1 rich  rich   70K Oct 12  2023  ssh.tar

That’s the contents of my home folder.

@mstormi, I don’t know if this is something caused by zram or by openHABian in some other way, but clearly find is broken somehow.

When I navigate to /var/lib/openhab/persistence/rrd4j and run the command I get back *all the files, even those more recent than 15 minutes.

󰐿 huginn  rich  …/openhab/persistence/rrd4j   10:19 
 find /var/lib/openhab/persistence/ -type f -mtime +15 | xargs ls -lh
total 2.0M
-rwxr-xr-x 1 openhab openhab   32 Sep  1 10:25 Readme.txt
-rw-r--r-- 1 openhab openhab 738K Sep 13 10:19 vDad_LR_Lum.rrd
-rw-r--r-- 1 openhab openhab 530K Sep 13 10:19 vDad_LR_Motion.rrd
-rw-r--r-- 1 openhab openhab 738K Sep 13 10:19 vDad_LR_Sensor_Battery.rrd

That “10:19” is when I ran the command.

No, that’s just showing the size of the directory reference.

There is something really weird going on that is making standard common tools like ls and find not work. I tried testing it on a non-zram folder and it seems to work as expected so I’m going to guess there’s something about zram that makes these commands behave strangely.


But at almost 1700 Items you probably are indeed running out of space so should increase the size of your zram1 partition as discussed above. I’m not sure the best way to look for old unused files. Maybe stop zram and then run the find command. If the ls looks reasonable replace the ls with rm as suggested and then start zram again. You probably will want to stop OH while you do all this.

You’ll still want to increase the size of zram1 though.

The command line is wrong…
My guess (can’t check for now, as I’m not at home):

find /var/lib/openhab/persistence/ -type f -mtime +15 -xargs ls -lh

So no pipe but a hyphen.

That command doesn’t work for me. I get “unknown predicate '-xargs`”.

I don’t think so. I’m running openHABian 1.9 on the Pi and accessing it via SSH through Terminus.

Would the +50 to 350M for mem_limit and +100 to 850 M for disk_size be enough to make a difference? The free command below shows 178 Mi free.

openhabian@oh-s:/var/log/openhab $ free -h
               total        used        free      shared  buff/cache   available
Mem:           3.8Gi       1.8Gi       178Mi       2.6Mi       1.9Gi       2.0Gi
Swap:          3.0Gi          0B       3.0Gi

Starting from

# swap  alg             mem_limit       disk_size       swap_priority   page-cluster    swappiness
swap    lzo-rle         300M            1G              75              0               150

# dir   alg             mem_limit       disk_size       target_dir                      bind_dir
dir     zstd            300M            750M            /var/lib/openhab/persistence    /persistence.bind

# log   alg             mem_limit       disk_size       target_dir              bind_dir                oldlog_dir
log     zstd            600M            1G              /var/log                /log.bind```

It’s hard to say. If we assume 738k per Item for rrd4j and roughly 8k per Item in mapdb an additional 50 MB would give you space for around 65 Items, give or take.

Keep in mind the “z” in zram stands for zip. Zram compresses the file system that it puts in memory so that 750MB space takes up significantly less RAM than 750MB.

Nah, pipe is correct.

Once you change it, don’t be shy. Based on your zramctl outoutput, you need to increase disksize only, make it 1G or a little more. I just made that the new default in openHABian, too.

Increased disk_size to 1 G

from etc/ztab:

# swap  alg             mem_limit       disk_size       swap_priority   page-cluster    swappiness
swap    lzo-rle         300M            1G              75              0               150

# dir   alg             mem_limit       disk_size       target_dir                      bind_dir
dir     zstd            300M            1G              /var/lib/openhab/persistence    /persistence.bind

# log   alg             mem_limit       disk_size       target_dir              bind_dir                oldlog_dir
log     zstd            600M            1G              /var/log                /log.bind
openhabian@oh-s:~ $ free -h
               total        used        free      shared  buff/cache   available
Mem:           3.8Gi       1.6Gi       355Mi       2.8Mi       1.9Gi       2.1Gi
Swap:          3.0Gi          0B       3.0Gi
openhabian@oh-s:~ $ 

Still seeing frequent errors:

2024-09-13 17:32:02.049 [ERROR] [d4j.internal.RRD4jPersistenceService] - Could not create rrd4j database file '/var/lib/openhab/persistence/rrd4j/Uverse_Channel_Up.rrd': Invalid file header. File [/var/lib/openhab/persistence/rrd4j/Uverse_Channel_Up.rrd] is not a RRD4J RRD file
2024-09-13 17:32:02.068 [ERROR] [d4j.internal.RRD4jPersistenceService] - Could not create rrd4j database file '/var/lib/openhab/persistence/rrd4j/Uverse_Pause.rrd': Invalid file header. File [/var/lib/openhab/persistence/rrd4j/Uverse_Pause.rrd] is not a RRD4J RRD file
2024-09-13 17:32:02.079 [ERROR] [d4j.internal.RRD4jPersistenceService] - Could not create rrd4j database file '/var/lib/openhab/persistence/rrd4j/Uverse_SkipForward.rrd': Invalid file header. File [/var/lib/openhab/persistence/rrd4j/Uverse_SkipForward.rrd] is not a RRD4J RRD file2024-09-13 17:32:02.102 [ERROR] [d4j.internal.RRD4jPersistenceService] - Could not create rrd4j database file '/var/lib/openhab/persistence/rrd4j/Weather_Current_Winddirection.rrd': Invalid file header. File [/var/lib/openhab/persistence/rrd4j/Weather_Current_Winddirection.rrd] is not a RRD4J RRD file
2024-09-13 17:32:02.112 [ERROR] [d4j.internal.RRD4jPersistenceService] - Could not create rrd4j database file '/var/lib/openhab/persistence/rrd4j/Weather_ForecastDay2_Cloudiness.rrd': Invalid file header. File [/var/lib/openhab/persistence/rrd4j/Weather_ForecastDay2_Cloudiness.rrd] is not a RRD4J RRD file
2024-09-13 17:32:02.144 [ERROR] [d4j.internal.RRD4jPersistenceService] - Could not create rrd4j database file '/var/lib/openhab/persistence/rrd4j/Weather_ForecastDay3_Apparentnight.rrd': Invalid file header. File [/var/lib/openhab/persistence/rrd4j/Weather_ForecastDay3_Apparentnight.rrd] is not a RRD4J RRD file
2024-09-13 17:32:02.152 [ERROR] [d4j.internal.RRD4jPersistenceService] - Could not create rrd4j database file '/var/lib/openhab/persistence/rrd4j/Weather_ForecastDay3_Gustspeed.rrd': Invalid file header. File [/var/lib/openhab/persistence/rrd4j/Weather_ForecastDay3_Gustspeed.rrd] is not a RRD4J RRD file
2024-09-13 17:32:02.201 [ERROR] [d4j.internal.RRD4jPersistenceService] - Could not create rrd4j database file '/var/lib/openhab/persistence/rrd4j/Weather_ForecastDay4_Uvindex.rrd': Invalid file header. File [/var/lib/openhab/persistence/rrd4j/Weather_ForecastDay4_Uvindex.rrd] is not a RRD4J RRD file
2024-09-13 17:32:02.204 [ERROR] [d4j.internal.RRD4jPersistenceService] - Could not create rrd4j database file '/var/lib/openhab/persistence/rrd4j/Weather_ForecastDay4_Windspeed.rrd': Invalid file header. File [/var/lib/openhab/persistence/rrd4j/Weather_ForecastDay4_Windspeed.rrd] is not a RRD4J RRD file
2024-09-13 17:32:02.228 [ERROR] [d4j.internal.RRD4jPersistenceService] - Could not create rrd4j database file '/var/lib/openhab/persistence/rrd4j/Weather_ForecastDay5_Rain.rrd': Invalid file header. File [/var/lib/openhab/persistence/rrd4j/Weather_ForecastDay5_Rain.rrd] is not a RRD4J RRD file
2024-09-13 17:32:02.278 [ERROR] [d4j.internal.RRD4jPersistenceService] - Could not create rrd4j database file '/var/lib/openhab/persistence/rrd4j/Weather_ForecastHours03_Apparenttemperature.rrd': Invalid file header. File [/var/lib/openhab/persistence/rrd4j/Weather_ForecastHours03_Apparenttemperature.rrd] is not a RRD4J RRD file
2024-09-13 17:32:02.283 [ERROR] [d4j.internal.RRD4jPersistenceService] - Could not create rrd4j database file '/var/lib/openhab/persistence/rrd4j/Weather_ForecastHours03_Gustspeed.rrd': Invalid file header. File [/var/lib/openhab/persistence/rrd4j/Weather_ForecastHours03_Gustspeed.rrd] is not a RRD4J RRD file
2024-09-13 17:32:02.287 [ERROR] [d4j.internal.RRD4jPersistenceService] - Could not create rrd4j database file '/var/lib/openhab/persistence/rrd4j/Weather_ForecastHours03_Precipprobability.rrd': Invalid file header. File [/var/lib/openhab/persistence/rrd4j/Weather_ForecastHours03_Precipprobability.rrd] is not a RRD4J RRD file
2024-09-13 17:32:02.332 [ERROR] [d4j.internal.RRD4jPersistenceService] - Could not create rrd4j database file '/var/lib/openhab/persistence/rrd4j/Weather_ForecastHours06_Apparenttemperature.rrd': Invalid file header. File [/var/lib/openhab/persistence/rrd4j/Weather_ForecastHours06_Apparenttemperature.rrd] is not a RRD4J RRD file
2024-09-13 17:32:02.335 [ERROR] [d4j.internal.RRD4jPersistenceService] - Could not create rrd4j database file '/var/lib/openhab/persistence/rrd4j/Weather_ForecastHours06_Dewpoint.rrd': Invalid file header. File [/var/lib/openhab/persistence/rrd4j/Weather_ForecastHours06_Dewpoint.rrd] is not a RRD4J RRD file
2024-09-13 17:32:02.339 [ERROR] [d4j.internal.RRD4jPersistenceService] - Could not create rrd4j database file '/var/lib/openhab/persistence/rrd4j/Weather_ForecastHours06_Precipprobability.rrd': Invalid file header. File [/var/lib/openhab/persistence/rrd4j/Weather_ForecastHours06_Precipprobability.rrd] is not a RRD4J RRD file
2024-09-13 17:32:02.347 [ERROR] [d4j.internal.RRD4jPersistenceService] - Could not create rrd4j database file '/var/lib/openhab/persistence/rrd4j/Weather_ForecastHours06_Winddirection.rrd': Invalid file header. File [/var/lib/openhab/persistence/rrd4j/Weather_ForecastHours06_Winddirection.rrd] is not a RRD4J RRD file
2024-09-13 17:32:02.367 [ERROR] [d4j.internal.RRD4jPersistenceService] - Could not create rrd4j database file '/var/lib/openhab/persistence/rrd4j/Weather_ForecastHours08_Cloudiness.rrd': Invalid file header. File [/var/lib/openhab/persistence/rrd4j/Weather_ForecastHours08_Cloudiness.rrd] is not a RRD4J RRD file
2024-09-13 17:32:02.389 [ERROR] [d4j.internal.RRD4jPersistenceService] - Could not create rrd4j database file '/var/lib/openhab/persistence/rrd4j/Weather_ForecastHours09_Temperature.rrd': Invalid file header. File [/var/lib/openhab/persistence/rrd4j/Weather_ForecastHours09_Temperature.rrd] is not a RRD4J RRD file
2024-09-13 17:32:02.411 [ERROR] [d4j.internal.RRD4jPersistenceService] - Could not create rrd4j database file '/var/lib/openhab/persistence/rrd4j/Weather_ForecastHours11_Pressure.rrd': Invalid file header. File [/var/lib/openhab/persistence/rrd4j/Weather_ForecastHours11_Pressure.rrd] is not a RRD4J RRD file
2024-09-13 17:32:02.428 [ERROR] [d4j.internal.RRD4jPersistenceService] - Could not create rrd4j database file '/var/lib/openhab/persistence/rrd4j/Weather_ForecastHours12_Windspeed.rrd': Invalid file header. File [/var/lib/openhab/persistence/rrd4j/Weather_ForecastHours12_Windspeed.rrd] is not a RRD4J RRD file
2024-09-13 17:32:02.430 [ERROR] [d4j.internal.RRD4jPersistenceService] - Could not create rrd4j database file '/var/lib/openhab/persistence/rrd4j/Weather_ForecastToday_Apparentday.rrd': Invalid file header. File [/var/lib/openhab/persistence/rrd4j/Weather_ForecastToday_Apparentday.rrd] is not a RRD4J RRD file
2024-09-13 17:32:02.463 [ERROR] [d4j.internal.RRD4jPersistenceService] - Could not create rrd4j database file '/var/lib/openhab/persistence/rrd4j/Weather_ForecastTomorrow_Maxtemperature.rrd': Invalid file header. File [/var/lib/openhab/persistence/rrd4j/Weather_ForecastTomorrow_Maxtemperature.rrd] is not a RRD4J RRD file
2024-09-13 17:32:02.466 [ERROR] [d4j.internal.RRD4jPersistenceService] - Could not create rrd4j database file '/var/lib/openhab/persistence/rrd4j/Weather_ForecastTomorrow_Nighttemperature.rrd': Invalid file header. File [/var/lib/openhab/persistence/rrd4j/Weather_ForecastTomorrow_Nighttemperature.rrd] is not a RRD4J RRD file
2024-09-13 17:32:02.469 [ERROR] [d4j.internal.RRD4jPersistenceService] - Could not create rrd4j database file '/var/lib/openhab/persistence/rrd4j/Weather_ForecastTomorrow_Pressure.rrd': Invalid file header. File [/var/lib/openhab/persistence/rrd4j/Weather_ForecastTomorrow_Pressure.rrd] is not a RRD4J RRD file
2024-09-13 17:32:02.511 [ERROR] [d4j.internal.RRD4jPersistenceService] - Could not create rrd4j database file '/var/lib/openhab/persistence/rrd4j/gGarlandLights.rrd': Invalid file header. File [/var/lib/openhab/persistence/rrd4j/gGarlandLights.rrd] is not a RRD4J RRD file
2024-09-13 17:32:02.528 [ERROR] [d4j.internal.RRD4jPersistenceService] - Could not create rrd4j database file '/var/lib/openhab/persistence/rrd4j/gThermostatsLowerTemperatureSettings.rrd': Invalid file header. File [/var/lib/openhab/persistence/rrd4j/gThermostatsLowerTemperatureSettings.rrd] is not a RRD4J RRD file
2024-09-13 17:32:02.541 [ERROR] [d4j.internal.RRD4jPersistenceService] - Could not create rrd4j database file '/var/lib/openhab/persistence/rrd4j/somecomfort1863934Upstairs_Temperature.rrd': Invalid file header. File [/var/lib/openhab/persistence/rrd4j/somecomfort1863934Upstairs_Temperature.rrd] is not a RRD4J RRD file
2024-09-13 17:32:02.548 [ERROR] [d4j.internal.RRD4jPersistenceService] - Could not create rrd4j database file '/var/lib/openhab/persistence/rrd4j/somecomfort1864745Master_Humidity.rrd': Invalid file header. File [/var/lib/openhab/persistence/rrd4j/somecomfort1864745Master_Humidity.rrd] is not a RRD4J RRD file

Any other suggestions?

you need to delete those broken files

I deleted all of the /var/lib/openhab/persistence/rrd4j files that were throwing error messages. There were 72 of them.

I noticed that it was the same files throwing an error. It looked like it tried every minute. That led me to discover the sort | uniq commands to get it down to unique file names.

I used this linux statement to find all of the files with this error in the openhab.log. I needed a little help from ChatGPT for the regular expression setup.

cat /var/log/openhab/openhab.log | grep -Po 'Invalid file header\. File \[\/var\/lib\/openhab\/persistence\/rrd4j\/\K[^\]]+' | sort | uniq

With a little more help from ChatGPT, I created a Bash script to remove them all at once. I first used the script w/o the rm command, just with echo, to make it would only list the suspect files.

  GNU nano 7.2                                                                                                                           myscript.sh                                                                                                                                    
#!/bin/bash
echo "Hello, this is a simple Bash script.";
cat /var/log/openhab/openhab.log | grep -Po 'Invalid file header\. File \[\/var\/lib\/openhab\/persistence\/rrd4j\/\K[^\]]+' | sort | uniq | while read -r file; do
    echo "$file" ;
        sudo rm "/var/lib/openhab/persistence/rrd4j/$file";
done

Its been 10 minutes since I deleted them, and no errors.

I guess the files had become corrupted and the corruption was copied on to the new SD card I started using last week.

I’ll wait until tomorrow to declare victory, but this is very promising. Thanks for all the help.

I deleted all of the files that were causing an error.

It was fine for a couple of days. Then 1 item started generating the error.

2024-09-23 17:34:06.198 [ERROR] [d4j.internal.RRD4jPersistenceService] - Could not create rrd4j database file '/var/lib/openhab/persistence/rrd4j/GPS_Tracker_GM_Region_Trigger_GMH_80Burgundy_50m.rrd': Invalid file header. File [/var/lib/openhab/persistence/rrd4j/GPS_Tracker_GM_Region_Trigger_GMH_80Burgundy_50m.rrd] is not a RRD4J RRD file

Two days later, a second item joined in:

2024-09-25 14:04:01.555 [ERROR] [d4j.internal.RRD4jPersistenceService] - Could not create rrd4j database file '/var/lib/openhab/persistence/rrd4j/GPS_Tracker_GM_Region_Trigger_GMH_80Burgundy_50m.rrd': Invalid file header. File [/var/lib/openhab/persistence/rrd4j/GPS_Tracker_GM_Region_Trigger_GMH_80Burgundy_50m.rrd] is not a RRD4J RRD file
2024-09-25 14:04:32.097 [ERROR] [d4j.internal.RRD4jPersistenceService] - Could not create rrd4j database file '/var/lib/openhab/persistence/rrd4j/SmartPowerStripMediaRoom_switch_s1.rrd': Invalid file header. File [/var/lib/openhab/persistence/rrd4j/SmartPowerStripMediaRoom_switch_s1.rrd] is not a RRD4J RRD file```

I can certainly delete these, but that doesn't seem like a real solution.