Improve RunWorkflowJob to reschedule in case of slow DB call to save workflow instance

This commit is contained in:
Sipke Schoorstra 2020-12-05 11:14:24 +01:00
parent 4f2233d980
commit 0cdd46f8ca

View file

@ -49,7 +49,11 @@ namespace Elsa.Activities.Timers.Jobs
if (workflowInstance == null)
{
_logger.LogWarning("Could not run Workflow instance with ID {WorkflowInstanceId} because it appears not yet to be persisted in the database. Skipping this round.", workflowInstanceId);
_logger.LogWarning("Could not run Workflow instance with ID {WorkflowInstanceId} because it appears not yet to be persisted in the database. Rescheduling.", workflowInstanceId);
var trigger = context.Trigger;
await context.Scheduler.UnscheduleJob(trigger.Key, cancellationToken);
var newTrigger = trigger.GetTriggerBuilder().StartAt(trigger.StartTimeUtc.AddSeconds(10)).Build();
await context.Scheduler.ScheduleJob(newTrigger, cancellationToken);
return;
}