Hi,
I am using hangfire (1.7.28) in a .NET 6 service with Hangfire.PostgreSql for storage.
Scheduling new jobs and executing/retrying them works fine as long as the service is running. If it crashes though none of the instances that where running at the time of the crash are getting retried on startup.
As far as i understand the documentation the expected behaviour would be that they rerun.
I am using custom states in case that matters but also experience the problem if the job is in the “Processing” state at time of the crash.
Here is my setup:
services.AddHangfire((provider, config) =>
{
config.UsePostgreSqlStorage(configurationRoot.GetValue<string>("DBConnectionString"))
.SetDataCompatibilityLevel(CompatibilityLevel.Version_170)
.UseSimpleAssemblyNameTypeSerializer()
.UseRecommendedSerializerSettings()
.UseFilter(new ElectStateFilter(provider.GetRequiredService<ConfigurationStorageProvider>(), provider.GetRequiredService<ILogger<ElectStateFilter>>()));
});
services.AddHangfireServer();
GlobalStateHandlers.Handlers.Add(new RemoteJobInitiatedState.Handler());
GlobalStateHandlers.Handlers.Add(new RemoteJobProcessingInitiatedState.Handler());
GlobalStateHandlers.Handlers.Add(new RemoteJobTransferInitiatedState.Handler());
GlobalStateHandlers.Handlers.Add(new DatabaseInsertInitiatedState.Handler());
Looking at the hangfire db i can see the in-progress jobs in the table “job” but they are obviously not getting picked up again.
What am i missing?
Thanks