

please me know,the issue is sometime
regard,
In my production environment this problem has started also. I don't know what happens since I didn't change anything.
@sergeyzwezdin Do you have any thoughts on this?
@gandarez, nope. Could you give more details?
@sergeyzwezdin I can't reproduce the error because it happened 3 times in about 5 months. The problem is the job can't run twice a day and I got duplicated values!!

@odinserj Do you have any thoughts on this?
do we encounter one of the issues common? this issue is sometime, i run to test, and i watch very especially common, I have a way to fixed: [Use lock object], I create a flag to lock process other.
I still look forward to how it runs 1 times.
@vknvnn, what Hangfire version, what storage, what storage version?
version 1.5.7, for MySql Storage 1.0.2 and Hangfire.SqlServer (= 1.5.7),
I was tested on 2 enviroment are SQL Server and MySQL,
I hope to have answers soon,
regard,
Heh, there are two packages for MySQL support: Hangfire.MySql and Hangfire.MySqlStorage. Looks like you are using the latter. I briefly looked into the source code, and found that MySqlServerQueue class implementation uses non-atomic query to fetch a job from queue. And if distributed lock isn't working as expected, you'll get the problem described above.
Please create an issue in Hangfire.MySqlStorage repository or try to use another package – queue implementation is much better there.
why are you close it? while it still to have issue in Hangfire.SqlServer (= 1.5.7)
this picture in take when i test in Hangfire.SqlServer (= 1.5.7)
please describe for me!
This problem is related to the Hangfire.MySqlServerStorage, that is a third-party extension I have no control under. So please file an issue there to attract attention of its author. This repository only contains source code for Hangfire.Core, Hangfire.SqlServer and Hangfire.SqlServer.Msmq packages.
Ah, now I see, you are using Hangfire.SqlServer also, sorry.
Please show me the logic you are using to configure Hangfire, and the whole screenshot of a job history page with the footer (that contains the SQL Server connection string).
sure [odinserj], But now I'm at home, Tomorrow on company, I will describe these configuration that i do, thank you because support me, I hope it work to I can demo for my boss.
regard,
Ah, now I see, you are using Hangfire.SqlServer also, sorry.
I'm also using Hangfire.SqlServer
@gandarez, can you show me your configuration logic and your Dashboard UI screenshot?
Are you using SQL Server, or SQL Azure?
@odinserj I'm using SQL Server 2008 R2 in the same LAN.
Here's the configuration logic
``` C#
GlobalConfiguration.Configuration.UseSqlServerStorage("Hangfire",
new SqlServerStorageOptions
{
QueuePollInterval = TimeSpan.FromSeconds(AppConfig.GetInt32("QueuePollInterval", 5))
})
.UseFilter(new AutomaticRetryAttribute
{
Attempts = AppConfig.GetInt32("AutomaticRetryAttempts", 3)
})
.UseFilter(new WorkflowJobFilter())
.UseFilter(new PreserveOriginalQueueAttribute());
_server =
new BackgroundJobServer(new BackgroundJobServerOptions
{
Queues = _queues.ToArray(),
SchedulePollingInterval = TimeSpan.FromSeconds(AppConfig.GetInt32("SchedulePollingInterval", 15)),
ServerTimeout = TimeSpan.Parse(AppConfig.GetString("ServerTimeout", "01:00"), CultureInfo.InvariantCulture)
});
```
What do you need from UI?
the content below is my configuration run in web mvc 5:
`public void Configuration(IAppBuilder app)
{
var builder = new ContainerBuilder();
var builderHangfire = new ContainerBuilder();
var config = new HttpConfiguration();
// Register your Web API controllers.
builder.RegisterApiControllers(Assembly.GetExecutingAssembly());
// Register your MVC controllers.
builder.RegisterControllers(Assembly.GetExecutingAssembly());
//Register Hangfire
GlobalJobFilters.Filters.Add(new AutomaticRetryAttribute { Attempts = 1 });
Hangfire.GlobalConfiguration.Configuration.UseSqlServerStorage("DefaultConnection");
var options = new DashboardOptions
{
AuthorizationFilters = new[]
{
new LocalRequestsOnlyAuthorizationFilter()
}
};
AutofacBootstrap.InitForeWeb(builder);
var container = builder.Build();
AutofacBootstrap.InitForHanfire(builderHangfire);
var containerHangfire = builderHangfire.Build();
//Hanfire
Hangfire.GlobalConfiguration.Configuration.UseAutofacActivator(containerHangfire);
//Api
config.DependencyResolver = new AutofacWebApiDependencyResolver(container);
//MVC
DependencyResolver.SetResolver(new AutofacDependencyResolver(container));
app.UseAutofacMiddleware(container);
app.UseAutofacWebApi(config);
WebApiConfig.Register(config);
app.UseAutofacWebApi(config);
app.UseWebApi(config);
app.UseAutofacMvc();
app.UseHangfireDashboard("/hangfire", options);
app.UseHangfireServer();
}
`
@vknvnn, @gandarez, thanks for the feedback! I've found non-synchronized access to a transaction which may cause Worker and Timer threads to access a connection instance (that is not thread safe) at the same time. In this case, the RemoveFromQueue method may throw an exception, which will lead to job re-queue as shown in the picture.
Hangfire 1.5.8 is just released!
@odinserj You rock!
Most helpful comment
@vknvnn, @gandarez, thanks for the feedback! I've found non-synchronized access to a transaction which may cause
WorkerandTimerthreads to access a connection instance (that is not thread safe) at the same time. In this case, theRemoveFromQueuemethod may throw an exception, which will lead to job re-queue as shown in the picture.