Cron Trigger not reliable

Hi @all,

my openHAB2 playground worked fine for many days. Suddenly it occurred a problem with my cron trigger. No idea, what is going wrong?
The trigger event should be executed once every minute. But as you can see in the event log, the trigger very often was executed 3 times in a minute. Sometimes it is running well. Sometimes it does not.
It is just a feeling that the problem started last week during an openHAB upgrade. But there is no proof for that.
Hope, anyone has some hint for my problem.
Thanks very much in advance.

Event log:
    2016-11-22 16:53:01.090 [ItemStateChangedEvent     ] - FBH_PWM_Takt changed from 0 to 10                                                    
    2016-11-22 16:53:02.116 [ItemStateChangedEvent     ] - FBH_PWM_Takt changed from 10 to 20                                                   
    2016-11-22 16:53:03.118 [ItemStateChangedEvent     ] - FBH_PWM_Takt changed from 20 to 30                                                   
    2016-11-22 16:54:01.086 [ItemStateChangedEvent     ] - FBH_PWM_Takt changed from 30 to 40                                                   
    2016-11-22 16:54:02.114 [ItemStateChangedEvent     ] - FBH_PWM_Takt changed from 40 to 50                                                   
    2016-11-22 16:54:03.123 [ItemStateChangedEvent     ] - FBH_PWM_Takt changed from 50 to 60                                                   
    2016-11-22 16:55:01.085 [ItemStateChangedEvent     ] - FBH_PWM_Takt changed from 60 to 70                                                   
    2016-11-22 16:55:02.111 [ItemStateChangedEvent     ] - FBH_PWM_Takt changed from 70 to 80                                                   
    2016-11-22 16:55:03.124 [ItemStateChangedEvent     ] - FBH_PWM_Takt changed from 80 to 90                                                   
    2016-11-22 16:56:01.089 [ItemStateChangedEvent     ] - FBH_PWM_Takt changed from 90 to 0                                                    
    2016-11-22 16:56:02.124 [ItemStateChangedEvent     ] - FBH_PWM_Takt changed from 0 to 10                                                    
    2016-11-22 16:56:03.137 [ItemStateChangedEvent     ] - FBH_PWM_Takt changed from 10 to 20                                                   

Rule:
Later, I inserted the sleep and the reentrant lock. But this did not change anything.

    rule "FBH PWM anwenden"                                                                                                                     

    when                                                                                                                                        
            Time cron "0 * * * * ?" // Timer jede Minute auslösen                                                                               

then                                                                                                                                        
        lock.lock()                                                                                                                         
        try {                                                                                                                               
        Thread::sleep(1000)                                                                                                                 
        // PWM Takt berechnen ---------------------------------------------------------------------------------------------------------
        var Number Takt = FBH_PWM_Takt.state                                                                                                
        Takt = Takt + 10                                                                                                                    
                                                                                                                                            
        if(Takt >= 100) Takt = 0                                                                                                            
        postUpdate(FBH_PWM_Takt,Takt)                                                                                                       
        }                                                                                                                                   
                                                                                                                                            
        finally {                                                                                                                           
                lock.unlock()                                                                                                               
        }                                                                                                                                   
)                                                                                                                                           
end

That cron runs every second, not every minute.

That doesn’t explain the behavior you are seeing though. For every minute you would use 0 0 * * * ?

It might be that you are exhausting the threadpool so only three can run a minute. I don’t know.

I wished the ground would open and swallow me up.
Didn´t saw it.

But
0 0 * * * ?

doesn´t work.
This one did it.

"0 0/1 * * * ?"

I assume, I have to read the manual again.
Thanks for your help.

On my system that runs every time the seconds are equal to 0, i.e. once a minute - see https://github.com/openhab/openhab/wiki/Rules#time-based-triggers - in Openhab the first field is seconds not minutes.

Having said that there is a problem with the scheduling of rules. A recent release corrected startup error messages, but in the process appears to have allowed the rules to run multiple times. Editing the rule reloads it and correctly schedules it. There are some other threads on the same subject see:

[Startup error for all cron based rules]
(Startup error for all cron based rules)

https://community.openhab.org/t/openhab2-cron-trigger-problems/17067

https://community.openhab.org/t/oh2-startup-rule-is-not-running/17038/2

My bad. Need more coffee. Obviously you are correct. I don’t know what I was thinking.

First I thought, I got the problem with the little change.
But after one hour of runnig, the cron trigger does strange things again.

So, this is still not working. Maybe an issue, of are there any errors from my side?

Sebastian

I’m seeing that as well.
Running a rule that request JSON-string from a website every 5 minutes. That was working well until the last weekend.
I first saw some “false” readings logged in my persistence, and then I got kicked from that website because of requesting the same 2,3 or even 5 times within seconds. Couldn’t change the log before I was kicked in order to show those multiple requests.