HangfireIO / Hangfire

An easy way to perform background job processing in .NET and .NET Core applications. No Windows Service or separate process required
https://www.hangfire.io
Other
9.43k stars 1.7k forks source link

Recurring job stops being executed after approximately 3 days with timezone set to local timezone #2462

Open DuplosFidibuss opened 3 weeks ago

DuplosFidibuss commented 3 weeks ago

Version

1.8.11 and 1.8.14

Storage package

Hangfire.InMemory 0.10.3

Configuration logic

services.AddHangfire(configuration => configuration
    .SetDataCompatibilityLevel(CompatibilityLevel.Version_180)
    .UseSimpleAssemblyNameTypeSerializer()
    .UseRecommendedSerializerSettings()
    .UseInMemoryStorage(new Hangfire.InMemory.InMemoryStorageOptions { MaxExpirationTime = System.TimeSpan.MaxValue})
);

services.AddHangfireServer(options =>
{
    options.Queues = ...; // company-specific code
    options.WorkerCount = 1;
});

services.AddHangfireServer(options =>
{
    options.Queues = ...; // company-specific code
    options.WorkerCount = 1;
});

services.AddHangfireServer(options =>
{
    options.Queues = ...; // company-specific code
    options.WorkerCount = 1;
});

Custom job filters

None

Problem

By scheduling a task using the following call:

recurringJobManager.AddOrUpdate(<taskId>, <queuePriority>, () => <methodCall>, <taskCron>, new RecurringJobOptions { TimeZone = TimeZoneInfo.Local });

The task is scheduled correctly and runs at the correct time for approximately 3 days. Afterwards it is no longer executed and in the dashboard we get phenomena like this:

image

In English, it is telling us that the next execution is 37 minutes ago which does not really make sense at all.

By omitting the part setting the time zone to the local time zone (that is, using the default time zone configuration UTC) with all other configuration remaining unchanged the task is scheduled and executed correctly for any length of time. Therefore we strongly assume a problem related to the timezone setting when calling the RecurringJobManager.

odinserj commented 3 weeks ago

Please try upgrading to the newest Hangfire.InMemory package 1.0.0, this problem was fixed in 0.10.4 as written here – https://github.com/HangfireIO/Hangfire.InMemory/issues/14.