Community Spring Cleaning week is here! Join your fellow Maveryx in digging through your old posts and marking comments on them as solved. Learn more here!

Alteryx Server Discussions

Find answers, ask questions, and share expertise about Alteryx Server.
SOLVED

Insuring Scheduled Jobs Do Not Run In Parallel

brianscott
11 - Bolide

Hello everyone - 

 

Let's say I've got a need to have a job to run every 2 minutes.  Most of the time, it isn't going to find any work to be done and will be done running in say 30 seconds.  But sometimes it does find work to do, and it might be a lot of work.  Let's say that this might make the job take 3 minutes to run.  We will call this execution A.  

 

Now two minutes have passed, and execution A is still running.  Having execution B get started and firing could be really problematic for me, weird data profiles, people getting double notified, etc.  Do I have to hack a way such that the job checks for a flag that gets set by the process?  Gurus give me some help.  Thanks. 

 

brian

2 REPLIES 2
DavidP
17 - Castor
17 - Castor

Interesting scenario!

 

I think this might work, not sure it's the best way.

 

I would create a file and save it somewhere with a single Boolean field such as "job running" and set it's value to false - see attachment.

 

When my workflow executes, the 1st thing it does is to load the file and use a test tool to check if the value is true or false. If the value is true, the test tool creates an error. In Runtime settings there's an option to cancel Running workflow on Error. This will stop the workflow going any further.

 

However, if the value is false, it will go to the 2nd branch of the block until done, turn "job running" to true, then proceed to execute your workflow. Once completed, "job running" is turned to false again.

 

See attached package for the full workflow and running test file.

 

stop workflow if instance running.png

brianscott
11 - Bolide

Hi David - 

 

Yeah, I was thinking of something similar.  If I was clever enough, I could probably build a small table somewhere that understood workflow names and macrofy the solution.  I'm likely to run into the issue again soon enough.  

 

Thanks!