Hangfire.Storage.DistributedLockTimeoutException: Timeout expired

Created on 31 Jan 2019  路  9Comments  路  Source: HangfireIO/Hangfire

Hi, I'm using Hangfire with Mssql.
I keep having timeout issues on recurring jobs.

Hangfire.Storage.DistributedLockTimeoutException
Timeout expired. The timeout elapsed prior to obtaining a distributed lock on the 'HangFire:HangfireBootstrapper.BackgroundTaskRunner.RunAll' resource.

Hangfire.Storage.DistributedLockTimeoutException: Timeout expired. The timeout elapsed prior to obtaining a distributed lock on the 'HangFire:HangfireBootstrapper.BackgroundTaskRunner.RunAll' resource.
at Hangfire.SqlServer.SqlServerDistributedLock.Acquire(IDbConnection connection, String resource, TimeSpan timeout)
at Hangfire.SqlServer.SqlServerConnection.AcquireLock(String resource, TimeSpan timeout)
at Hangfire.SqlServer.SqlServerConnection.AcquireDistributedLock(String resource, TimeSpan timeout)
at Hangfire.DisableConcurrentExecutionAttribute.OnPerforming(PerformingContext filterContext)
at Hangfire.Server.BackgroundJobPerformer.InvokePerformFilter(IServerFilter filter, PerformingContext preContext, Func`1 continuation)

Any idea how to fix that?

Thanks

question

Most helpful comment

Hi has anyone found a solution to this yet?

All 9 comments

I am having the same issue. I have this attribute on my method:

[DisableConcurrentExecution(timeoutInSeconds: 10 * 60)]

In my case it is a recurring task that executes every hour.

Having the same problem over here. Is there some configuration missing? Am using RavenDB for storage.

Hangfire.Server.DelayedJobScheduler:Debug: An exception was thrown during acquiring distributed lock on the locks:schedulepoller resource within 60 seconds. The scheduled jobs have not been handled this time.
It will be retried in 15 seconds

Hangfire.Storage.DistributedLockTimeoutException: Timeout expired. The timeout elapsed prior to obtaining a distributed lock on the 'HangFire/locks:schedulepoller' resource.
at Hangfire.Raven.DistributedLocks.RavenDistributedLock.Acquire(TimeSpan timeout)
at Hangfire.Raven.DistributedLocks.RavenDistributedLock..ctor(RavenStorage storage, String resource, TimeSpan timeout, RavenStorageOptions options)
at Hangfire.Raven.RavenConnection.AcquireDistributedLock(String resource, TimeSpan timeout)
at Hangfire.Server.DelayedJobScheduler.UseConnectionDistributedLockT
Hangfire.Server.RecurringJobScheduler:Debug: An exception was thrown during acquiring distributed lock the recurring-jobs:lock resource within 60 seconds. The recurring jobs have not been handled this time.

Hangfire.Storage.DistributedLockTimeoutException: Timeout expired. The timeout elapsed prior to obtaining a distributed lock on the 'HangFire/recurring-jobs:lock' resource.
at Hangfire.Raven.DistributedLocks.RavenDistributedLock.Acquire(TimeSpan timeout)
at Hangfire.Raven.DistributedLocks.RavenDistributedLock..ctor(RavenStorage storage, String resource, TimeSpan timeout, RavenStorageOptions options)
at Hangfire.Raven.RavenConnection.AcquireDistributedLock(String resource, TimeSpan timeout)
at Hangfire.Server.RecurringJobScheduler.UseConnectionDistributedLock(JobStorage storage, Func`2 action)

Hi has anyone found a solution to this yet?

Happening for me too. I wish to find a solution to this. Again, it's only for long running jobs that run into each other.

Having the same issue w a Long running job

Set QueuePollInterval to 30 and it resolved the issue for me.

@kashyapus u mean QueuePollInterval = TimeSpan.FromSeconds(30) (30 seconds or other value u meant?
Thanks in advance for answer :)

@kashyapus u mean QueuePollInterval = TimeSpan.FromSeconds(30) (30 seconds or other value u meant?
Thanks in advance for answer :)

Yes you are correct. TimeSpan.FromSeconds(30)

What does QueuePollInterval when set to a higher value actually do? Does it decrease the amount of polls per timespan?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

vikramjb picture vikramjb  路  3Comments

cottsak picture cottsak  路  3Comments

plmwong picture plmwong  路  3Comments

dbones picture dbones  路  3Comments

thurfir picture thurfir  路  4Comments