I have read this thread : http://support.backendless.com/t/timer-executed-multiple-times
and I have the same problem. In addition sometimes the timer is not executed, after launching coderunner it says timer started in the past … waiting for events. but nothing happens.
The timer was working without any problem. Then I started to test things, removing and adding services, timers … and the behavior is totally unpredictable. Sometimes runs 3 times and stops running, sometimes it just doesn’t run, sometimes several instances of the same timer seem to be running
The timer functionality :
The timer increments a Counter and puts in cache an object obtained from the DB using the counter as index. For testing the table just had 10 rows so eventually an exception was being thrown. At that point I was reseting the counter and launching the coderunner again, what was working at the beginning but I wonder if somehow affected the strange behavior.
Thank you in advance
Alfredo,
Is your timer running in the cloud (production) or your own machine (debug) ?
Mark
Hi Mark
It’s in debug
Did you happen to use the “Run Now” button in console to run the timer?
I started using the “Run Now” button only after it stopped executing. This morning I tried, I just launched coderunner and a 120 sec timer is executing twice in that time
Does the timer run more predictably if you do not click the Run Now button?
I’m not clicking any button Mark. Just running CodeRunner.sh and the timer gets executed several times in the time it is supposed to execute once.
That’s is the “normal” behavior… however sometimes the timer does not get executed, It says “waiting for events” but nothing happens… then and only then if I want to execute I click the run button and it executes but again in a very unpredictable manner, sometimes executes once and stop, sometimes executes several times in its due time span.
How frequently is the timer configured to run? Could you please post your @BackendlessTimer annotation here? I’d like to try the same on my machine.
@BackendlessTimer("{'startDate':1455352620000,'frequency':{'schedule':'custom','repeat':{'every':120}},'timername':'dailyInfoScheduler'}")
This will work fine(I think) in your machine as it did in mine. It’s after using it for several times, adding and removing code when the strange behavior started.
If I could run a test case I would test the following:
Launch a timer which executes fine 1 or more times, then change something without stopping the timer (like a Counter) that makes the execute method throw an exception, after the exception is thrown the timer keeps going so without stopping it fix what was creating the exception (In my case I reset a Counter) and then the timer executes again without any problem. Now stop the timer and check if after starting it again the execution time is right.
I could be totally wrong(sorry if I am) but maybe that was causing two instances of the timer run at the same time.
If I understood correctly, the timer starts misfiring if you make a change in the code and then the body of the timer throws exception. But if you restart the timer, it is working fine again?
If I restart the timer it does Not work fine
When you stop code runner, does the timer still show up in the Debug tab of Backendless console?
No , it’s not there anymore
Hello,
The issue had been fixed, please run your timer at least one time with button “Run now” and timer execution will be recovered.
Please notify us ASAP if you notice some timer misbehaviours.
Best regards,
Artur