How to prevent Hangfire from restarting after a restart after 30 minutes of continuous execution

I am working on an asp.net mvc-5 web application and have encountered a problem when using the Hangfire tool to run lengthy background jobs. the problem is that if the execution of the task exceeds 30 minutes, then the freeze will automatically initiate another task, so as a result I will get two identical tasks at the same time.

Now I have the following: -

  1. Asp.net MVC-5
  2. MIS-8
  3. Hangfire 1.4.6
  4. Windows Server 2012

Now I have identified a recurring shoot-out mission that will run every day at 5 p.m. The background task basically scans our network for servers and vms and updates the database, and the repeated task will send an email after completion. Repetitive work worked well when it was less than 30 minutes. But today, when our system is expanding, repetitive work is completed in 40 minutes instead of 22-25 minutes, as it was before. and I received 2 emails instead of one email (and the time between emails was about 30 minutes). Now I restart the task manually and noticed that the problem is as follows: -

" 30 , , , 2 . "

, 30 (, 29 ), , 30 , - - . , hangfire , , , , sql, , . 30 ( 17:30), 2 , , 2 .

- , , , 30 ?

+8
4

InvisibilityTimeout Hangfire?

SQL Server . , , .

, UPDATE OUTPUT FetchedAt ( , ) . . ( 30 ).

, , . :

  • ( ) 12:00.
  • B 12:30, .
  • C ( ) 13:00, ( .)

, 12:30, 13:00 B. , . , WorkerA B ( 12:30), C , .

, , :

var options = new SqlServerStorageOptions
{
    InvisibilityTimeout = TimeSpan.FromMinutes(30) // default value
};

GlobalConfiguration.Configuration.UseSqlServerStorage("<name or connection string>", options);

Hangfire 1.5 Obsolete. , , .

30 ( ) SQL . Hangfire.SqlServer .

, - .

+18

, Postgresql, , , - sqlserver. , - PostgreSqlStorageOptions, : https://github.com/frankhommers/Hangfire.PostgreSql/blob/master/src/Hangfire.PostgreSql/PostgreSqlStorageOptions.cs#L36. , , UsePostgreSqlStorage , . .Net Core 2.0 hangfire postgresql ConfigureServices ( 30 ):

    services.AddHangfire(config =>
            config.UsePostgreSqlStorage(Configuration.GetConnectionString("Hangfire1ConnectionString"), new PostgreSqlStorageOptions {
                InvisibilityTimeout = TimeSpan.FromMinutes(720)

            }));
+6

Hangfire.MemoryStorage . FetchNextJobTimeout MemoryStorageOptions, 30 , .

var options = new MemoryStorageOptions
{
    FetchNextJobTimeout = TimeSpan.FromDays(1)
};
GlobalConfiguration.Configuration.UseMemoryStorage(options);
+1

, , , :

Hangfire 1.5 . , , .

30 ( ) SQL Server. Hangfire.SqlServer .

, , - .

, , MySQL, PostgreSQL, MongoDB, InvisibilityTimeout : https://github.com/HangfireIO/Hangfire/issues/1197

0

Source: https://habr.com/ru/post/1613753/


All Articles