Scheduling hope and best practices?

If you have questions or if you want to share your opinion about Aware IM post your message on this forum
BobK
Posts: 544
Joined: Thu Jan 31, 2008 2:14 pm
Location: Cincinnati, Ohio, USA

Re: Scheduling hope and best practices?

Post by BobK »

Rem wrote: Fri Apr 23, 2021 2:16 pm
BobK wrote: Fri Apr 23, 2021 1:43 pm For the 3 processes scheduled to run at 10 AM are all 3 in a different rules and each rule has a condition like IF CURRENT_TIME = '10:00''?

There is no guarantee that the scheduler starts exactly on the 00 second, for example it could start at 10:00:20.
If the scheduler starts at 10:00:20 and your first process runs for 25 seconds and the second process runs for another 25 seconds, the time will be 10:01:10 when the condition on the third process is evaluated. The times will not match and the process will not run.
This is interesting ...

Question: are you referring to three different processes that, using the scheduler, are set to start at the same time or one process which starts another and then yet another?

If the first scenario, then this seems odd because in my world the processes would run simultaneously?
If the second scenario, why should the nested process bother about the clock (and so on)..
The processes I am referencing are Henrik's, so I am not exactly sure how the are setup. My answer assumes they are set up in the schedule as:

Rule 1
IF CURRENT_TIME='10:00' THEN Process1

Rule 2
IF CURRENT_TIME='10:00' THEN Process2

Rule 3
IF CURRENT_TIME='10:00' THEN Process3
Bob
hpl123
Posts: 2579
Joined: Fri Feb 01, 2013 1:13 pm
Location: Scandinavia

Re: Scheduling hope and best practices?

Post by hpl123 »

BobK wrote: Fri Apr 23, 2021 1:54 pm
hpl123 wrote: Fri Apr 23, 2021 9:44 am Today all processes executed as scheduled and I will keep monitoring this, can´t believe I never thought about this before or set up some control mechanism before :oops: .

When it comes to the problem yesterday, the strange thing is I have 3 processes scheduled to run at 10 am and 2 of them did run but not the third one and is very strange, as some processes are executed the scheduler works and is doing what it should but it misses a process?
For the 3 processes scheduled to run at 10 AM are all 3 in a different rules and each rule has a condition like IF CURRENT_TIME = '10:00''?

There is no guarantee that the scheduler starts exactly on the 00 second, for example it could start at 10:00:20.
If the scheduler starts at 10:00:20 and your first process runs for 25 seconds and the second process runs for another 25 seconds, the time will be 10:01:10 when the condition on the third process is evaluated. The times will not match and the process will not run.
Yes, all rules are scheduled to run at 10 am so I have 3 of these:

Code: Select all

If CURRENT_TIME='10:00'  then Process
Again the strange part is 2 out of 3 processes executed yesterday, why would Aware do that? Each of the 3 processes could take over a minute to run if it has to execute many operations (send various emails, SMS etc.) and that was the reason I wondered if these were executed after each other instead of in parallel. If executed in parallel, all process would run at the same time but if not, the first process may take 40 seconds which means the second process would "make it" for scheduled execution at '10.00' but if that process then also takes 40 seconds, the third process would not "make it" as when the second process is done, the time would be '10.01'.
Henrik (V8 Developer Ed. - Windows)
hpl123
Posts: 2579
Joined: Fri Feb 01, 2013 1:13 pm
Location: Scandinavia

Re: Scheduling hope and best practices?

Post by hpl123 »

BobK wrote: Fri Apr 23, 2021 2:01 pm
hpl123 wrote: Fri Apr 23, 2021 9:52 am
BobK wrote: Thu Apr 22, 2021 9:40 pm I look at the Scheduling as a special Process that runs automatically about every 60 seconds.
Makes sense this is how it works and things like this should ideally be logged somewhere i.e logged internally in the Aware logs. Is this logged somewhere i.e when the scheduler checks and executes scheduled processes? From what I can see, these processes and not logged in the regular production log and the server logs are very difficult to look at and see things that happened in the past. It would be very useful if we either knew how to look at a scheduler specific log or if scheduler events were shown in the production etc. logs as well.
Because of the issues with the logs, I do not use them much. But I believe that to get the rules executed via the scheduler to appear in the logs you need to select "Level of logging" of either "All server events excluding SQL" or "All server events including SQL"
I tested this last night and think I had full logs activated and the scheduled events did not get entries in the logs. Trying tonight again with full logs just to make sure.
Henrik (V8 Developer Ed. - Windows)
aware_support
Posts: 7523
Joined: Sun Apr 24, 2005 12:36 am
Contact:

Re: Scheduling hope and best practices?

Post by aware_support »

Aware IM executes timer events in different threads. However, if a CPU is quite busy executing previous timer handlers and/or user requests, it is possible that the timer handler waits for the CPU to become free and misses its 60 seconds window.

So if you have a rule that checks for the exact time, it may miss an event occasionally. You need to handle this at the application level - the solutions outlined in this forum thread are quite valid.
Aware IM Support Team
hpl123
Posts: 2579
Joined: Fri Feb 01, 2013 1:13 pm
Location: Scandinavia

Re: Scheduling hope and best practices?

Post by hpl123 »

hpl123 wrote: Fri Apr 23, 2021 7:26 pm
BobK wrote: Fri Apr 23, 2021 2:01 pm
hpl123 wrote: Fri Apr 23, 2021 9:52 am

Makes sense this is how it works and things like this should ideally be logged somewhere i.e logged internally in the Aware logs. Is this logged somewhere i.e when the scheduler checks and executes scheduled processes? From what I can see, these processes and not logged in the regular production log and the server logs are very difficult to look at and see things that happened in the past. It would be very useful if we either knew how to look at a scheduler specific log or if scheduler events were shown in the production etc. logs as well.
Because of the issues with the logs, I do not use them much. But I believe that to get the rules executed via the scheduler to appear in the logs you need to select "Level of logging" of either "All server events excluding SQL" or "All server events including SQL"
I tested this last night and think I had full logs activated and the scheduled events did not get entries in the logs. Trying tonight again with full logs just to make sure.
Look like it does show scheduler events when you have full logs with SQL etc. enabled.
Henrik (V8 Developer Ed. - Windows)
PointsWell
Posts: 1457
Joined: Tue Jan 24, 2017 5:51 am
Location: 'Stralya

Re: Scheduling hope and best practices?

Post by PointsWell »

hpl123 wrote: Mon Apr 26, 2021 9:34 pm
hpl123 wrote: Fri Apr 23, 2021 7:26 pm
BobK wrote: Fri Apr 23, 2021 2:01 pm

Because of the issues with the logs, I do not use them much. But I believe that to get the rules executed via the scheduler to appear in the logs you need to select "Level of logging" of either "All server events excluding SQL" or "All server events including SQL"
I tested this last night and think I had full logs activated and the scheduled events did not get entries in the logs. Trying tonight again with full logs just to make sure.
Look like it does show scheduler events when you have full logs with SQL etc. enabled.
Seems like there should be a more obvious way to switch on login for scheduled processes, or rather the switch label should be more obvious. I have a process that I am trying to debug that generates a lot of erroneous records and debugging is a PITA.
gernotlg
Posts: 80
Joined: Fri Aug 27, 2021 1:24 am

Re: Scheduling hope and best practices?

Post by gernotlg »

BobK wrote: Thu Apr 22, 2021 9:40 pm 2) If a process crashes because of an internal error, the Switch for that process never gets set back to No, so this process would never run again. For this situation, I have another process that runs about every 15 minutes and checks each ControlRecord. If the ControlRecord Switch is Yes and the ControlRecord TimeStarted is more than 30 minutes ago, the Switch is reset to No. Under normal processing, my processes should not take 30 minutes to complete.
Is there a way to find out if a process is running programmatically. ?

I know that if we log in as admin we see the currently running processes in the system, and then cancel that process if we want, but in order to automate the cancelling of a Hung process, it would be good to be able to access the Active Processes query programmatically and then programmatically Cancel a process.

I'm just saying, because even if you check ControlRecord every 15 minutes (or whenever), and then mark a process as Switch = 'No', that process might still be running.... but just stuck.
V8.8 / Windows / MySQL
kklosson
Posts: 1617
Joined: Sun Nov 23, 2008 3:19 pm
Location: Virginia

Re: Scheduling hope and best practices?

Post by kklosson »

I had several scheduled processes that stopped working after a platform update. Turns out some were stating the time as 1400 and some were stating the time as 14:00. Those without the colon were broken.
V8.8
MySQL, AWS EC2, S3
PDFtk Toolkit
hpl123
Posts: 2579
Joined: Fri Feb 01, 2013 1:13 pm
Location: Scandinavia

Re: Scheduling hope and best practices?

Post by hpl123 »

gernotlg wrote: Mon Nov 27, 2023 10:44 pm
BobK wrote: Thu Apr 22, 2021 9:40 pm 2) If a process crashes because of an internal error, the Switch for that process never gets set back to No, so this process would never run again. For this situation, I have another process that runs about every 15 minutes and checks each ControlRecord. If the ControlRecord Switch is Yes and the ControlRecord TimeStarted is more than 30 minutes ago, the Switch is reset to No. Under normal processing, my processes should not take 30 minutes to complete.
Is there a way to find out if a process is running programmatically. ?

I know that if we log in as admin we see the currently running processes in the system, and then cancel that process if we want, but in order to automate the cancelling of a Hung process, it would be good to be able to access the Active Processes query programmatically and then programmatically Cancel a process.

I'm just saying, because even if you check ControlRecord every 15 minutes (or whenever), and then mark a process as Switch = 'No', that process might still be running.... but just stuck.

Well, not a pretty one. If you know a little bit about databases, SQL etc. you can write some script or similar to dig through the execution_context table and empty the table to clear out all active processes. You can probably also figure out how to find and cancel/delete 1 particular row in the table for a particular process etc..
Henrik (V8 Developer Ed. - Windows)
Post Reply