Search code examples
c#.netmongodb.net-corehangfire

Hangfire recurring job next execution time is empty


This question may seem pretty dumb, so sorry about that. I'm new to Hangfire.

I'm using hangfire(with MongoDB) in my .net core app and things are good!

But yesterday I got the following errors for my recurring jobs using.

System.InvalidOperationException: 
Recurring job can't be scheduled, see inner exception for details. 
---> Hangfire.Common.JobLoadException: Could not load the job. See inner exception for the details. 
---> System.TypeLoadException: 
Could not load type 'AirQualityControl.Core.Models.Domain.AirMonitoringStation' from assembly 'AirQualityControl.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'.   at System.Reflection.RuntimeAssembly.GetType(QCallAssembly assembly, String name, Boolean throwOnError, Boolean ignoreCase, ObjectHandleOnStack type, ObjectHandleOnStack keepAlive, ObjectHandleOnStack assemblyLoadContext)   at System.Reflection.RuntimeAssembly.GetType(String name, Boolean throwOnError, Boolean ignoreCase)   at System.TypeNameParser.ResolveType(Assembly assembly, String[] names, Func`4 typeResolver, Boolean throwOnError, Boolean ignoreCase, StackCrawlMark& stackMark)   at System.TypeNameParser.ConstructType(Func`2 assemblyResolver, Func`4 typeResolver, Boolean throwOnError, Boolean ignoreCase, StackCrawlMark& stackMark)   at System.TypeNameParser.GetType(String typeName, Func`2 assemblyResolver, Func`4 typeResolver, Boolean throwOnError, Boolean ignoreCase, StackCrawlMark& stackMark)   at System.Type.GetType(String typeName, Func`2 assemblyResolver, Func`4 typeResolver, Boolean throwOnError)   at Hangfire.Common.TypeHelper.DefaultTypeResolver(String typeName)   at System.Linq.Enumerable.SelectArrayIterator`2.ToArray()   at Hangfire.Storage.InvocationData.DeserializeJob()   --- End of inner exception stack trace ---   at Hangfire.Storage.InvocationData.DeserializeJob()   at Hangfire.RecurringJobEntity..ctor(String recurringJobId, IDictionary`2 recurringJob, ITimeZoneResolver timeZoneResolver, DateTime now)   --- End of inner exception stack trace ---   at Hangfire.Server.RecurringJobScheduler.ScheduleRecurringJob(BackgroundProcessContext context, IStorageConnection connection, String recurringJobId, RecurringJobEntity recurringJob, DateTime now)
enter code here

This is completely my fault 🤦‍♀️ , 'cause I accidentally change the type namespace. I revert those changes to previous state.

But I'm worried about current state of jobs:

enter image description here

As you might see the next execution is empty.

Usually it contains date and time when job will be triggered next time.

enter image description here

So I guess that they will not be lunch according to CRON expression?

Do I need to somehow manually tweak these jobs?

Or they will run today at 7PM again according to CRON expression?

Thank you so much for your help and have a nice day!


Solution

  • Update: For those who are new to Hangfire and facing the same issue.

    Every job in Hangfire has a certain number of retries attempts. It might be a global setting or could be changed using the AutomaticRetry attribute per job.

    By default every job has 10 retries attempt.

    If retry attempts exceeded their maximum, the job will be move to the Failed state (with an error log message), and you will be able to retry it manually.

    Also, it's important to note that we might see hangfire with it's jobs as a finite-state machine.

    enter image description here This image has an illustrational purpose only. This is not an accurate list of hangfire job's states

    That means that every job should have a certain state. Some of them are terminal and some of them are not.

    Here you could find a complete list of hangfire's job states.

    According to the documentation

    Failed - Defines the intermediate state of a background job when its processing was interrupted by an exception and it is a developer's responsibility to decide what to do with it next.

    That means that job would not be triggered automatically and you should run it manually or get rid of it.