Azure / azure-functions-durable-extension

Durable Task Framework extension for Azure Functions
MIT License
711 stars 263 forks source link

StartAt option is being ignored during ScheduleNewOrchestrationInstanceAsync #2751

Open ursaciuc-adrian opened 4 months ago

ursaciuc-adrian commented 4 months ago

Description

When I use ScheduleNewOrchestrationInstanceAsync, I set the StartAt value from StartOrchestrationOptions expecting the orchestration to start at that time. However, it's not happening as I thought, and instead, it starts right away.

This is causing a big problem because we have jobs that are supposed to happen regularly, but now they're running way too often, like 500k times a day.

This used to work fine in version 1.0.3. I reported the same issue about a year ago, and it got fixed back then. But now, it's broken again.

https://github.com/microsoft/durabletask-dotnet/issues/131

Expected behavior

The StartAt option should be respected when scheduling an orchestration.

Actual behavior

The StartAt option is being disregarded, leading to the orchestration running immediately instead of at the specified time.

Relevant source code snippets

var options = new StartOrchestrationOptions
{
    InstanceId = recordId,
    StartAt = nextOccurrence (e.g DateTime.UtcNow.AddDays(1))
};

var input = new ExecuteScheduledReportInput(report.ID, recordId, report.CronSchedule);
await client.ScheduleNewOrchestrationInstanceAsync(nameof(ExecuteScheduledReportOrchestration), input, options);

Known workarounds

Could use something like to simulate the scheduling, but would prefer to have the StartAt function working

DateTime dueTime = context.CurrentUtcDateTime.AddHours(72); await context.CreateTimer(dueTime, CancellationToken.None);

App Details