I found out that calling lastUpdate in a rule causes very high cpu usage when the influxdb is offline. The problem can only be solved by completely restarting openHAB. I also tested what happens if maximumSince is called, but this does not seem to cause this problem.
Every rule that calls lastUpdate on an offline influxdb creates a thread that uses up a whole cpu core. I have multiple rules that use lastUpdate, so this brought my whole system down several times when I restarted the influxdb.
I was able to reproduce this problem with a new Docker container running a fresh openHAB instance. Also the problem can be reproduced with Linux (Debian) and Windows 10.
Steps to Reproduce
-
Create an number item NUM_Test that is persisted in influxdb.
-
Create a rule that can be triggered manually with the following line:
var ZonedDateTime lastUpdate = NUM_Test.lastUpdate("influxdb")
-
Shut down the influxdb.
-
Trigger the rule.
-
Run
top -H -p PROCESS_ID
with the process id of openhab. There should be a rule thread that is now using up a whole cpu core.
Here is a screenshot from top:
I already created an issue on GitHub for this: [influxdb] High cpu usage when calling lastUpdate on offline InfluxDB database. · Issue #19313 · openhab/openhab-addons · GitHub
I’ve created this thread so this issue can also be found in the forum.