Open dhiaayachi opened 1 month ago
This issue appears to stem from the way Temporal currently interprets the combination of an interval and a start time when creating a schedule.
The problem:
Explanation:
The behavior you're observing is likely due to Temporal's internal implementation of interval-based schedules. When you specify an interval, it calculates the next occurrence of that interval after the provided "StartAt" time. In your case, specifying "every 365 days" with a "StartAt" of June 19th results in the next occurrence of the interval being December 18th, which is indeed 6 months later.
Temporal's Expected Behavior:
Temporal currently aligns the first run of a schedule with the next occurrence of the specified interval after the provided "StartAt" time. This is a different behavior from a cron schedule where the "StartAt" time directly dictates the initial run, while subsequent runs follow the cron expression.
Possible Workarounds:
As of now, Temporal lacks a direct way to override this behavior and have the first run strictly follow the specified "StartAt" time while adhering to the interval. Here are some potential workarounds:
Using Cron Expressions: Instead of specifying intervals, use cron expressions that align with your desired schedule. This provides more granular control over the timing of runs and allows you to specify the exact start time for the first run.
Using a temporary 'Start Delay': Create a schedule with an interval and an initial "StartAt" that is a short delay from the desired "StartAt" time. This way, Temporal will align the first run with the next occurrence of the interval after the initial delay, effectively matching your desired "StartAt" time.
Using a Child Workflow: Create a parent workflow that starts a child workflow at your desired "StartAt" time. The child workflow can then be responsible for handling the interval logic. This allows you to separate the initial start time from the subsequent interval-based runs.
Future Enhancements:
You can submit a feature request to Temporal to improve schedule creation functionality and allow users to specify the exact start time for the first run while adhering to the desired interval.
References:
Note:
Temporal is constantly evolving, so these limitations may be addressed in future releases. Keep an eye out for updates to the Temporal documentation and SDKs for any new features or changes related to schedule management.
Thanks for reporting this! It seems you've stumbled upon an issue with how Temporal handles schedules with a 365-day interval.
Currently, Temporal calculates the first run of a schedule based on the time it's created, even if you specify a StartAt
time. This behavior might be unexpected, as it doesn't directly align with the intended StartAt
time.
Here's a potential workaround:
StartAt
time.We understand this is a known issue and are actively working on improving the scheduling behavior to better align with user expectations.
Let us know if you have any other questions!
Today is June 19th, 2024. If you create a schedule and specify "every 365 days" the result will be that the first run is on
2024-12-18 00:00:00
. That's in 6 months. I've tried passingStartAt: 2025-06-19
but I get2025-12-18 00:00:00
as a result.I understand this may be known and as-designed behavior but it struck me as unexpected to ask for a 365 day interval, yet the first run is within the next 6 months.
I also don't see any way to achieve my desired result. Am I missing anything?
EDIT: I also can't use the offset to control this behavior because I don't know what the final calculation will be until the schedule is created.
Expected Behavior
In the example above, I'd prefer to have the schedule's first run be at my specified "StartAt". So, if I say:
"Start this workflow every 365 days with start at 2025-02-03 04:05:06", then the upcoming runs would look like:
Actual Behavior
When I pick 365 days as the interval, I seem to be getting a date 6 months in the future.
Steps to Reproduce the Problem
Specifications