When Hangfire deployed in Azure webjob , multiple webjobs instances picks same hangfire job
- I am using paid version of hangfire , version number 1.6.21.
- I have deployed Hangfire in Azure webjob
- I am Using Azure SQL server as Database for Hangfire
- When I run below query on Hangfire.State table , I see multiple records for “In Progress” state for same hangfire jobid
- This happens in 3 cases , when Azure instances scaled down or it becomes un-available or if same job is picked by 2 instances simultaneously.
- All above scenarios are intermittent and happens for less than 5% of the jobs.
- Is there any quick code fix or workaround ? Because Upgrading to latest hangfire or Using combination of Service bus and Azure function will take time
Select jobid, count (servername) from [HangFire].[State] with(nolock) where [JobId] in (1,2,3)
group by jobid having count(servername)>1