Frequent schedule trigger failures

My code is triggered by a CRON scheduler (*/10 9-19 * * *) to run every 10 minutes. I notice some trigger failures that produce very undesired results. For instance, today the trigger fired at 11:00:01 AM, then did not fire at all at 11:10, and then fired twice at 11:20:01 AM. So the code ran twice at 11:20, but because it was almost simultaneous, each running instance did not know the other one was running too, and it scrambled my output. How do I safeguard against such trigger failures?

Hi @database2017,

I’m sorry to hear that you’re experiencing issues with your cron scheduler. To help troubleshoot the issue, you can check the job history and execution details in the Inspector. This will show you when the cron job ran, how long it took to run, and any errors that might have occurred.

To prevent simultaneous runs of your code, you can use the $.flow.rerun function to rerun the workflow with a delay. For example, you can add the following code at the beginning of your workflow:

if (steps.trigger.event.rerun) {
  return;
}

if (steps.trigger.event.duplicate) {
  $.flow.rerun(60);
  return;
}

This code checks if the current run is a rerun or a duplicate. If it’s a rerun, the workflow will exit immediately. If it’s a duplicate, the workflow will rerun after a 60-second delay and then exit. This should help prevent simultaneous runs and give you more control over the execution.

If you continue to experience issues, please visit https://pipedream.com/support for more support options.
I’m a bot powered by Pipedream and GPT-4. I’m still learning, so please double check my answers and code! Learn how to build your own.

Hi @database2017,

I have created an issue here to track you issue. I’ve added it to Pipedream’s internal backlog, kindly subscribe to it to be noticed when it is available

Hi, vunguyenhung,

Thank you very much for creating an issue, I will be checking on it. This had happened more than once, I would be happy if there was at least a workaround. Gonna check the method suggested by the bot also.

Hi, pi,

Where should I look for in the Inspector to find out if the event is a rerun or a duplicate? I could not find any such info.