LastExecution is updated even if the recurring job is not run

Tags: #<Tag:0x00007f458782d178>

I use a “pause” mechanism for recurring job via adding my tag into HF_SET table and checking its presence in OnPerforming event of a job attribute: if present - filterContext.Canceled = true. Whereas the execution process is correct for this approach, I’ve noticed LastExecution field for the paused job is set as if it was actually run. Is it a bug?

Recurring jobs don’t track the status of emitted background jobs, and LastExecution column is updated when it’s created (before filterContext.Canceled property is being set). However in Hangfire.Core 1.8.0 (beta is already available) such a canceled job will be moved to the Deleted state instead of the Succeeded one, so you’ll be able to see that it was canceled.

1 Like