Hello all,
tl;dr overlap policy support for cron workflows
I am have a bunch of Temporal workflows with a cron schedule, I realized that some of them are long running and they might overrun the next scheduled run e.g (A workflow is schedule to run once every hour, but sometimes might take 1.5 hours to execute).
In this case, is there anything I can do to not “miss” a run in the schedule if there is an overlap? I see the suggestion is to migrate to schedules (Which takes in an overlap policy) but this won’t be feasible at the moment. Thank you!
Hi @Abdelrahman_Abouzeid
Another approach is having a workflow that manages the schedule.
You can have a parent workflow with a loop:
- that schedules a child workflow with Parent_close_policy=Abandon (or an external workflow using an activity) ,
- calculate the remaining time before scheduling the next execution (it will be close to 1 hour) and sleep
- schedule the next child workflow. Note that you will need to set unique workflowsIds. By default, it has to be unique for running workflows in the namespace.
- at some point, you will need to continue_as_new to prevent hitting the event history limit. In python you can use is_continue_as_new_suggested from Workflow.info
Let us know if it helps.
Antonio
1 Like