Best way to troubleshoot missed rules?

I’ve been in the middle of migrating action/trigger processing from Vera to openHAB via the awesome MiOS binding. While the process has been somewhat laborious, it’s also been positive.

However, I do notice while openHAB is generally pretty responsive, it does miss some rules on some occasions. The frequency of a missed rule (i.e. turn on closet light on motion/lock door on close) is maybe only 5 percent of the time, but it’s enough to be noticeable and slightly annoying.

Has anyone seen anything similar? Does anyone happen to have suggestions for troubleshooting the causes?

Since this is a new openHAB deployment, i’m logging at debug level and I don’t see anything immediately obvious which would indicate any problems. The test machine is a full blown windows box with plenty of resources.

Thanks in advance!

I used to see this type of thing under openHAB 1.6, but I made two key changes that eliminated the issues:

[ul][li]a) I fixed a Threading issue in openHAB Core impacting Rule execution.
The case it exercised involved having 2 or more Rules “sharing” the same Trigger. As you grow your system, this tends to happen more and more frequently, and it was hit-n-miss as to whether you’d see the problem (and partly, how fast your Processor is)

If you haven’t already, move up to openHAB 1.7.0 to pickup the change.

[/li]
[li]b) I moved to using locking in my Rules.
openHAB fires off your code using one thread per concurrent Rule execution. If you’ve got 3 rules, and they all fire “near” to each other, then they could all be running at the same time (each via different Rule execution contexts). This is very different from the Vera model, where stuff is [largely] running serially.

As a result, it’s possible for resources in one of the Rule contexts to need to be locked by another. The most common case occurs when you’re using sharable resources like Timers in your Rules, but there are other cases also.

See these examples, using ReentrantLock objects, for examples of the coding style:
MiOS Binding Example · openhab/openhab1-addons Wiki · GitHub
[/li][/ul]

Anyhow, before going further, take a crack and (a) and (b) above. If you still have problems, I can look at the logs to see if there’s anything obviously amiss (if provided in concert with the Rule & Item defs, and the timeframe of the key events, I can also double check if there’s something else wrong)

Separately, I was also having issues with the Nest Binding, due to a different set of threading problems. These have been sorted by @watou in the latest Nest Binding, and also more broadly fixed in 1.7.1 Core (releasing this week).

These will impact a few different Bindings, based upon where they’re at in the code but if you’re only running the MiOS Binding it’s unlikely you’ll hit those issues.

Guessed,

Deeply appreciate your suggestions. Your helpfulness is tremendous!

I’m actually running openHAB 1.8 built by cloudbees. Coincidentally, I moved up from 1.7 to 1.8 in an attempt to get around similar issues in 1.7 and @watou’s binding (whether 1.8 is fixing or contributing to problems remains to be seen! haha).

The concurrent threads you outlined in B must be a major contributor since many of my rules rely on timers. I’ll take a closer look at my existing rules to and try out your advice.

Thanks again for pointing me towards the right direction!

How did you get on?

Whoa. sorry for the long delay! I’ve been slammed at work and haven’t been on the boards in a while. Just saw this.

Actually, everything has gone surprisingly smooth. After implementing the locks, all function related to openhab have been very stable and reliable. Since things have been so busy at work, I haven’t tinkered with the openhab install (on the odroid XU4) since moving it into production about a month ago. Rules fire fast and reliably all the time.

As everyone has already said before me, the learning curve is high, but the results of working with openhab are quite positive. I’m very happy with our current setup with Vera handling zwave and openhab doing everything else.

There are a lot of thoughts I’d love to share with the community comparing openhab and PLEG as rules engines. Of course there are some advantages/disadvantages of each, but I’ll need to spend some time to commit them to paper. Hopefully sometime soon!