Hangfire failing after moving clock forward - for the daylight saving time

Firstly, thanks for creating hangfire…
Secondly, we started have issues today as we moved to daylight saving time (Central Standard time(CST) to Central Daylight time(CDT)) and none of the jobs are getting triggered after that. Please see the exception throw below. Could you please let me know how to fix this

2016-03-13 08:33:00.743 -05:00 [Error] Error occurred during execution of ‘RecurringJobScheduler’ process. Execution will be retried (attempt 12 of 2147483647) in 00:02:16 seconds.
System.ArgumentException: The supplied DateTime represents an invalid time. For example, when the clock is adjusted forward, any time in the period that is skipped is invalid.
Parameter name: dateTime
at System.TimeZoneInfo.ConvertTime(DateTime dateTime, TimeZoneInfo sourceTimeZone, TimeZoneInfo destinationTimeZone, TimeZoneInfoOptions flags, CachedData cachedData)
at Hangfire.Server.ScheduleInstant.b__0(DateTime x)
at System.Linq.Enumerable.WhereSelectEnumerableIterator2.MoveNext() at System.Collections.Generic.List1…ctor(IEnumerable1 collection) at System.Linq.Enumerable.ToList[TSource](IEnumerable1 source)
at Hangfire.Server.ScheduleInstant.GetNextInstants(Nullable1 lastInstant) at Hangfire.Server.RecurringJobScheduler.TryScheduleJob(JobStorage storage, IStorageConnection connection, String recurringJobId, IReadOnlyDictionary2 recurringJob)
at Hangfire.Server.RecurringJobScheduler.Execute(BackgroundProcessContext context)
at Hangfire.Server.ServerProcessExtensions.Execute(IServerProcess process, BackgroundProcessContext context)
at Hangfire.Server.AutomaticRetryProcess.Execute(BackgroundProcessContext context)

One fix I figured out after investigation is delete [HangFire].[Set] and [HangFire].[Hash] tables and reload the scheduled jobs.

Do we have any other elegant way of fixing this…

I second this. All of our jobs have been failing since daylight savings time came into effect. The only way I see to fix this is to delete our jobs and re-create them. But what about when we hit daylight savings time again in the fall? Anyone have any success in fixing this?

Hi,
Are there any plans to fix this bug?
Could this have been avoided by using Cron.Hourly rather than explicitly specifying a cron expression?
What can we do to prevent this from happening in the future?

NCrontab may return invalid date and time values, since it doesn’t know anything about time zones and/or daylight savings. This change allows Hangfire to skip those values when calculating next execution time for recurring jobs.

I’ve fixed this and just released Hangfire 1.5.4, it skips all the invalid date time values.

2 Likes