Skip to content

Jobs are always removed after one day, regardless of the MaxExpirationTime value #16

@DuplosFidibuss

Description

@DuplosFidibuss

Version

Hangfire 1.8.14

Storage package

Hangfire.InMemory 0.10.3 and 1.0.0

Configuration logic

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

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

According to the documentation in the C# code the MaxExpirationTime attribute should overwrite any other job retention behaviour configured. Since we do not want the jobs to be removed at all until we shut down the program (RAM is not so much a concern in our case) we first tried to set the value of this attribute to System.TimeSpan.MaxValue and afterwards to null which should disable the automatic deletion according to the GitHub documentation. In both cases the jobs are still removed after 1 day. In the dashboard we get the following phenomenon:
image
That is, the counter on the left side displays 12 jobs (and that is the right number), but 9 of them occurred more than 24 hours before the screenshot was taken, so they are no longer listed in the job list.
If the expiration time behaviour can be turned off by setting the attribute to null, we expect it to behave this way and not delete any jobs while the program is running.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions