I'm using Hangfire to run jobs that take roughly 2 hours. I have noticed that every 30 minutes the job re occurs while the previous one is still working. So If I have Job A which starts at a specific time, after 30 minutes another job A will start running while previous one is still in processing state.
ConfigureServices():
services.AddHangfire(config => config
.UseSimpleAssemblyNameTypeSerializer()
.UseDefaultTypeSerializer()
.UseMemoryStorage());
services.AddHangfireServer();
Configure():
app.UseHangfireDashboard();
RecurringJob.AddOrUpdate<ISender>(i => i.A(), Cron.Daily(8, 0), timeZone: TimeZoneInfo.Local);
I have checked the Method which is run for errors, exceptions and etc, just to make sure job is not retried because of that. I think that's not a case after a lot of testing.
any kind of help would be appreciated
I'm not sure if this is right way, but it solved the problem for me.
It was caused by UseMemoryStorage() in ConfigureServices().
Passing options like the example below will restrict a job to reoccur after 30 minutes by default or whatever will be indicated in options.
var options = new MemoryStorageOptions
{
FetchNextJobTimeout = TimeSpan.FromHours(10)
};
services.AddHangfire(config => config.SetDataCompatibilityLevel(CompatibilityLevel.Version_170)
.UseSimpleAssemblyNameTypeSerializer()
.UseDefaultTypeSerializer()
.UseMemoryStorage(options));