openhab / openhab-addons

Add-ons for openHAB
https://www.openhab.org/
Eclipse Public License 2.0
1.88k stars 3.58k forks source link

[rrd4j] Could not create rrd4j database file #13297

Closed dandjo closed 2 years ago

dandjo commented 2 years ago

When using RRD4j as persistence service i constantly get the following error when setting up a MQTT Item with the setup described below.

[ERROR] [d4j.internal.RRD4jPersistenceService] - Could not create rrd4j database file /var/lib/openhab/persistence/rrd4j/mqtt_testung_item.rrd': null

  1. Install a MQTT broker (Mosquitto)
  2. Install and configure the MQTT broker bridge (no special configuration)
  3. Configure a MQTT Thing with bridge from above
  4. Add a channel with identifier mqtt_testung_channel with state- and command-topic mqtt_testung_topic and Wh as measurement unit
  5. Link and add an Item mqtt_testung_item with type Number:Energy, semantic class Measurement and semantic property Energy (I assume that those details are not very relevant)
  6. Add a rule with name mqtt_testung_rule with a trigger of your choice (one that gets updated frequently) and a script as follows (note that smartpi_ptot is also my trigger state) image DSL: events.sendCommand('mqtt_testung_item', itemRegistry.getItem('smartpi_ptot').getState());

When removing the rule, the error is gone in the openhab log. I'm not sure if this is because no command is posted anymore or if this is for other reasons.

System environment:

runtimeInfo:
  version: 3.3.0
  buildString: Release Build
locale: en-AT
systemInfo:
  configFolder: /etc/openhab
  userdataFolder: /var/lib/openhab
  logFolder: /var/log/openhab
  javaVersion: 11.0.16
  javaVendor: Ubuntu
  osName: Linux
  osVersion: 5.15.0-1013-raspi
  osArchitecture: aarch64
  availableProcessors: 4
  freeMemory: 145644896
  totalMemory: 223346688
  startLevel: 100
bindings:
  - mqtt
  - netatmo
  - tado
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: false
    cordova: false
    phonegap: false
    electron: false
    nwjs: false
    webView: false
    webview: false
    standalone: false
    pixelRatio: 1
    prefersColorScheme: light
  isSecureContext: false
  locationbarVisible: true
  menubarVisible: true
  navigator:
    cookieEnabled: true
    deviceMemory: N/A
    hardwareConcurrency: 8
    language: de-AT
    languages:
      - de-AT
      - de
      - en-US
      - en
    onLine: true
    platform: Linux x86_64
  screen:
    width: 3440
    height: 1440
    colorDepth: 24
  support:
    touch: false
    pointerEvents: true
    observer: true
    passiveListener: true
    gestures: false
    intersectionObserver: true
  themeOptions:
    dark: dark
    filled: true
    pageTransitionAnimation: default
    bars: light
    homeNavbar: default
    homeBackground: default
    expandableCardAnimation: default
  userAgent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like
    Gecko) Chrome/104.0.0.0 Safari/537.36
timestamp: 2022-08-14T22:20:49.075Z
wborn commented 2 years ago

Did you check if openHAB can create/update files in /var/lib/openhab/persistence/rrd4j? Perhaps the issue is caused by wrong permissions or insufficient available free disk space.

dandjo commented 2 years ago

Yes I did, there's is plenty of disk space and the permissions are correct. There are also other Items which are not able to write. Items with null values. Maybe that's the reason?

wborn commented 2 years ago

Can you create a file in the directory yourself? It could also be the disk is mounted as read only by the kernel due to corruption.

dandjo commented 2 years ago

Yes, already checked permissions and file-system related stuff. The error even occur with permissions 777 on the parent directory.

Flole998 commented 2 years ago

Is that file actually nonexistent? I got that error sometimes aswell even though the file always existed, so there was no need for it to be created. Somewhere in the forum or here there's additional information about this.

dandjo commented 2 years ago

The file exists, is writeable and gets written most of the time. Occasionally the error occurs. That's weird, and I think not related to a file system issue.

wborn commented 2 years ago

If those files are stored in ZRAM, some occasional ZRAM hiccups could also be causing it.

dandjo commented 2 years ago

No ZRAM here at all.

image

wborn commented 2 years ago

Add a rule with name mqtt_testung_rule with a trigger of your choice (one that gets updated frequently) and a script as follows (note that smartpi_ptot is also my trigger state)

Perhaps it's a concurrency issue. The add-on doesn't seem to keep track of the RrdDbs it opens because there could be many as one is created for each item... so it could cause exceptions if it tries to open a DB while it is still writing to it in another thread.

dandjo commented 2 years ago

Good point, since the described setup triggers the item update event twice as I figured out in an other debugging session. But I guess there are plenty of scenarios like this. In my opinion the rrdb should be able to handle this.

openhab-bot commented 1 year ago

This issue has been mentioned on openHAB Community. There might be relevant details there:

https://community.openhab.org/t/rrd4j-doesnt-work-for-rollershutter/140532/2