Azure Data Factory ADFV2 Trigger Overlap - triggers

I have a ADFV2 trigger that runs every 2 minutes. The pipeline that is called usually takes just over a minute to run but sometimes it takes over 2 minutes but if that happens the trigger kicks in again and runs regardless of the previous trigger still running or not. Is there any way to stop this overlap?
The trigger needs to run every 2 minutes.
Thanks.

There is a concurrency setting in the pipeline definition. Set it to 1. The trigger will create an event, but it will be set to Queued state until previous job completes

Related

What is the behavior of ADF schedule triggers when a schedule starts before the previous one ends?

I am trying to contrast and find the exact behavior of ADF schedule triggers and ADF thumbing window triggers when a trigger starts before the previous pipeline triggered by the schedule ends?
For example, let’s say we have a every 5 min schedule but the pipeline takes one hour to finish. What happens to all the every-5-min triggers that happen until the pipeline is finished?
Are the behaviors of thumbing window and schedule triggers the same in this scenario?
When using the ADF schedule trigger (shorter recurrence time than the amount of time pipeline takes to execute), the pipeline starts executing (In progress state) every time it is triggered irrespective of the previous pipeline run status.
Using the trigger with 3-minute recurrence interval produced the following output.
The tumbling window trigger reacts in the same way as a schedule trigger. The pipeline starts execution irrespective of the status of previous run. The trigger used has a 5-minute recurrence interval.
So, in this scenario both types of triggers behave in the same way. But tumbling window triggers have a self-dependency property which is not available with Schedule triggers. If the consecutive pipeline runs depend on each other, the self-dependency property can be used. Other significant differences between these triggers, including the self-dependency property are mentioned in the following Microsoft Q&A link.
https://learn.microsoft.com/en-us/answers/questions/207405/when-to-use-tumbling-window-type-trigger.html

Why does Data Factory Pipeline scheduled trigger sometimes gets offset?

I have some scheduled daily running pipelines.
Sometimes the scheduled trigger start time [Run start time] gets offset by few seconds [1s to 5s].
This is happening to all the pipelines having the same trigger.
Some of pipes use IR and some of them don't.
Trying to understand why it's happening.
Ex. Pipeline trigger offset by 1 second
Ashwin, yes this happens sometimes maybe due to a lag / latency between a trigger to start and actual start of a pipeline just like you clicking a button and time taken by the event behind that button to occur
But this does not hamper the execution of your pipeline

Azure Data Factory - tumbling window trigger will not start (stuck in the past)

I have pipelines that I need to run in sequence. The first is a "raw to bronze," which runs daily at 4am. Once that completes, I want my "bronze to silver" to kick off. Raw to bronze is running just as expected (tumbling window every 24 hours), and it successfully completes. Bronze to silver is configured as a tumbling window trigger with dependency on raw to bronze, but its window is stuck in November 2021. I have tried combinations of offset and window size (0 offset to fire immediately, and a +4 hour window size to run in the next 4 hours), but the problem remains. I have also deleted and re-created the trigger. Still the dependency window is November 2021.
raw to bronze configuration:
bronze to silver configuration:
And when I look at trigger runs, I see the window is stuck in the past:
Any ideas what I might be missing? All I am wanting is for the bronze to silver to kick off immediately after raw to bronze completes. Raw to bronze takes about an hour to run.
Thanks in advance for any help!
I repro’d in my lab, and it worked when I started the 2nd tumbling trigger (which is dependent on trigger 1) a minute before the dependency trigger (A_to_B).
Tumbling trigger A_to_B:
Tumbling trigger B_to_C:
Created this trigger to start 1 min earlier than the dependency trigger (A_to_B).
While creating it, it asks to re-align offset for dependency by the difference time as shown in the below snip.
Trigger runs:
First B_to_C trigger starts with status as waiting on dependency. A minute later A_to_B trigger starts running and when completes it changes the status to succeed. Now B_to_C trigger starts running and completes successfully.

Creating dependency between Azure Datafactory Scheduled triggers

I have 2 scheduled triggers in Azure Data factory pipelines, lets say T1 and T2.
I want to have the trigger T2 to run after the trigger T1 is completed.
Does Azure Data factory has a mechanism to achieve the same for scheduled triggers?
Basically I want the Trigger T2 to start executing only after the trigger T1 is completed
Below is the more clear requirement
1)1st pipeline is starting at 10 AM and runs long till 11 AM
2)2nd pipeline is starting at 10.30 AM, so I need this 2nd pipeline to wait till the 1st one completes and even if the 1st one completes before 10.30, 2nd should start only at scheduled time of 10.30 not before that
Use a Web Activity at the end of the 1st scheduled pipeline. That Web Activity will send a message to Event Grid which T2 is listening on, using the Event Grid trigger. Once that message is received, pipeline 2 will activate. Here's an example: https://www.youtube.com/watch?v=FpKrBLeqdj4
I was able to produce the expected coordination between pipelines by using a look up in the second pipeline, ie the 2nd pipeline will look for the file/result which should be put in a blob location when the 1stpipeline completes.
The lookup in the 2nd pipeline should have no of retries with higher numbers (10 or 20) and retry interval every 30 mins.
This will make the 2nd pipeline wait for the completion of 1st pipeline

Stop running Azure Data Factory Pipeline when it is still running

I have a Azure Data Factory Pipeline. My trigger has been set for every each 5 minutes.
Sometimes my Pipeline takes more than 5 mins to finished its jobs. In this case, Trigger runs again and creates another instance of my Pipeline and two instances of the same pipeline make problem in my ETL.
How can I be sure than just one instance of my pipeline runs at time?
As you can see there are several instances running of my pipelines
Few options I could think of:
OPT 1
Specify 5 min timeout on your pipeline activities:
https://learn.microsoft.com/en-us/azure/data-factory/concepts-pipelines-activities
https://learn.microsoft.com/en-us/azure/data-factory/concepts-pipelines-activities#activity-policy
OPT 2
1) Create a 1 row 1 column sql RunStatus table: 1 will be our "completed", 0 - "running" status
2) At the end of your pipeline add a stored procedure activity that would set the bit to 1.
3) At the start of your pipeline add a lookup activity to read that bit.
4) The output of this lookup will then be used in if condition activity:
if 1 - start the pipeline's job, but before that add another stored procedure activity to set our status bit to 0.
if 0 - depending on the details of your project: do nothing, add a wait activity, send an email, etc.
To make a full use of this option, you can turn the table into a log, where the new line with start and end time will be added after each successful run (before initiating a new run, you can check if the previous run had the end time). Having this log might help you gather data on how much does it take to run your pipeline and perhaps either add more resources or increase the interval between the runs.
OPT 3
Monitor the pipeline run with SDKs (have not tried that, so this is just to possibly direct you):
https://learn.microsoft.com/en-us/azure/data-factory/monitor-programmatically
Hopefully you can use at least one of them
It sounds like you're trying to run a process more or less constantly, which is a good fit for tumbling window triggers. You can create a dependency such that the trigger is dependent on itself - so it won't run until the previous run has completed.
Start by creating a trigger that runs a pipeline on a tumbling window, then create a tumbling window trigger dependency. The section at the bottom of that article discusses "tumbling window self-dependency properties", which shows you what the code should look like once you've successfully set this up.
Try changing the concurrency of the pipeline to 1.
Link: https://www.datastackpros.com/2020/05/prevent-azure-data-factory-from-running.html
My first thought is that the recurrence is too frequent under these circumstances. If the graph you shared is all for the same pipeline, then most of them take close to 5 minutes, but you have some that take 30, 40, even 60 minutes. Situations like this are when a simple recurrence trigger probably isn't sufficient. What is supposed to happen while the 60 minute one is running? There will be 10-12 runs that wouldn't start: so they still need to run or can they be ignored?
To make sure all the pipelines run, and manage concurrency, you're going to need to build a queue manager of some kind. ADF cannot handle this itself, so I have built such a system internally and rely on it extensively. I use a combination of Logic Apps, Stored Procedures (Azure SQL), and Azure Functions to queue, execute, and monitor pipeline executions. Here is a high level break down of what you probably need:
Logic App 1: runs every 5 minutes and queues an ADF job in the SQL database.
Logic App 2: runs every 2-3 minutes and checks the queue to see if a) there is not a job currently running (status = 'InProgress') and 2) there is a job in the queue waiting to run (I do this with a Stored Procedure). IF this state is met: execute the next ADF and update its status to 'InProgress'.
I use an Azure Function to submit jobs instead of the built in Logic App activity because I have better control over variable parameters. Also, they can return the newly created ADF RunId, which I rely in #3.
Logic App 3: runs every minute and updates the status of any 'InProgress' jobs.
I use an Azure Function to check the status of the ADF pipeline based on RunId.