HangfireIO / HangfireIO/Hangfire

Long task fire multi times

Open
#1,202 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
C#
Stars
10.1k
Forks
1.8k
Avg merge
1h 19m
Merged PRs (30d)
1

Description

I test a long task:
class AClass {
public void Hahaha(int i) {
_logger.LogError("Message from AClass.hahaha begin " + i.ToString());
Thread.Sleep(5000);
_logger.LogError("Message from AClass.hahaha end " + i.ToString());
}
}
BackgroundJob.Enqueue(c => c.Hahaha(t))

then I got this:

2018-06-08 15:54:44,273 ERROR [Worker #81645ab9] ?.? - Message from AClass.hahaha begin 1682564419
2018-06-08 15:54:46,086 ERROR [Worker #3317f49e] ?.? - Message from AClass.hahaha begin 1682564419
2018-06-08 15:54:48,084 ERROR [Worker #7bd544a0] ?.? - Message from AClass.hahaha begin 1682564419
2018-06-08 15:54:49,279 ERROR [Worker #81645ab9] ?.? - Message from AClass.hahaha end 1682564419
2018-06-08 15:54:51,093 ERROR [Worker #3317f49e] ?.? - Message from AClass.hahaha end 1682564419
2018-06-08 15:54:53,089 ERROR [Worker #7bd544a0] ?.? - Message from AClass.hahaha end 1682564419

My config:
GlobalConfiguration.Configuration.UseStorage(
new MySqlStorage(GetMysqlConnectionString(), new MySqlStorageOptions
{
TransactionIsolationLevel = IsolationLevel.ReadCommitted,
QueuePollInterval = TimeSpan.FromSeconds(15),
JobExpirationCheckInterval = TimeSpan.FromHours(1),
CountersAggregateInterval = TimeSpan.FromMinutes(5),
PrepareSchemaIfNecessary = true,
DashboardJobListLimit = 50000,
TransactionTimeout = TimeSpan.FromMinutes(1),
}));
How to avoid this?

Contributor guide

Open the contributing guide

Research direction

Reproduce the behavior with the shown AClass.Hahaha method and BackgroundJob.Enqueue call, then trace how the configured MySqlStorage and worker polling handle the long-running job. Check whether the repeated starts are expected retries or duplicate processing; done should establish the cause and provide a verified way to prevent unintended multiple executions.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp, mysql
Domain
backend, databases, distributed-systems
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.