Sometimes Slow System since Update to 2.5.1-2

  • Platform information: Rasperry Pi 3B+
    • Hardware: ARM/1GB RAM Running on SSD (not SD)
    • OS: Raspbian Current (All packages up to date)
    • Java Runtime Environment: which java platform is used and what version
    • openHAB version: 2.5.1-2
  • Issue of the topic:
    My System is running for years now, it started with OH 2.0 and was upgraded thru years until 2.5.1-2.
    Since Update to 2.5.0 I have a strange behaviour!!!
    The System is running very well normally. But sometimes it takes up to 5 Minutes until a rule is triggered. Than the LOAD on the Raspi is higher then “normal”. Here’s a screenshot of normal operation (everything works fast):

Here’s an example Rule ofthe slow behaviour explained.
The Item “i_mqtt_WemosMiniAkku_1_Distanz” triggers a rule where some calculations are done and a other Item is updated. (See rule code below). The rule triggers normally ever 30 Minutes (48 times a day). 40 Times everything is working fast, the rule is triggered immediatly after the Item is updated and then it takes about 1 second to work thru the rule.
Sometimes (about 8 times a day) it takes up to 5 minutes until the rule is triggered. Once the trigger is fired the rule worked thru in a second (the logs below)

  • Please post configurations (if applicable):
    • Items configuration related to the issue
    • Sitemap configuration related to the issue
    • Rules code related to the issue:
rule "Zisterne Ultraschallsensor Abstand ermitteln"
when
    Item i_mqtt_WemosMiniAkku_1_Distanz received update 
then
	// Variable für Abstand
	var double Abstand	

	// Abstand nur ermitteln, wenn DISTANZ ungleich UNDEF ist z.B. nach einem Neustart
	if ( (i_mqtt_WemosMiniAkku_1_Distanz.state != UNDEF) ){
		// Aktuellen Abstand in Variable einlesen
		val DecimalType AbstandState = i_mqtt_WemosMiniAkku_1_Distanz.state as DecimalType
		
		Abstand = AbstandState.doubleValue
		
		//Abstand auf 0 Nachkommastellen runden
		Abstand = java.lang.Math.round(100 * Abstand )/100
		logInfo("Zisterne.rules", "Abstand: " + Abstand)

		i_mqtt_Zisterne_Abstand.postUpdate(Abstand)

	}
end
  • Services configuration related to the issue
  • If logs where generated please post these here using code fences:
    Example “slow triggering rule” (about 90 seconds until Loginfo):
events.log:
2020-01-15 **05:29:59.128** [vent.ItemStateChangedEvent] - i_mqtt_WemosMiniAkku_1_Distanz changed from 58.368 to 58.298

openhab.log:
2020-01-15 **05:31:28.250** [INFO ] [marthome.model.script.Zisterne.rules] - Abstand: 58

Example normally (fast triggering rule). Runs within a second:

event.log:
2020-01-15 **18:00:21.689** [vent.ItemStateChangedEvent] - i_mqtt_WemosMiniAkku_1_Distanz changed from 59.544 to 59.526

openhab.log:
2020-01-15 **18:00:21.713** [INFO ] [marthome.model.script.Zisterne.rules] - Abstand: 59

In “Error condition” the LOAD is 1.6 0.8 0.7
This behaviour is only an example. It also appears from time to time with other rules. So it’s a system wide issue.
As far as I figured out are not the rules itself the problem, but the triggering of the rules.
The triggering takes very long due to the “high” load.

I read a lot of Threads here and found some optimizations.
What I have done so far:

  • eliminated all Thread:Sleep in all rules. (Only using Timers for time based operations)

  • All executeCommandLine and sendHttpGetRequest are only started within a Timer. Example:

createTimer(now, [ |
        executeCommandLine("sudo /app/scripts/openhab/gethndwerte.sh", 60000)
])

I have tried everthing but can’t find a solution.
I assume that “something” (Maybe a rule, binding, what ever) is creating high load on the Raspberry Pi. Then the triggering of the rules is delayed (up to 5 minutes I saw in the logs)
After the load goes down, everything is working fast.

Here’s also a threads --list output vom karaff shell:

Maybe someone has an suggestion what I could try else. I don’t have any further ideas!!

Thanks a lot in advance

Helmar

WAs running out of threads.
so I added:

org.eclipse.smarthome.threadpool:ruleEngine=20

to runtime.cfg

Found the solution here: