Per the Hangfire 0.8.2 announcement post, Hangfire has a DisableConcurrentExecution
filter which, when applied to a method, prevents multiple instances of the method from executing concurrently.
The DisableConcurrentExecution
filter takes a timeoutInSeconds
int parameter. From the example in the linked article:
[DisableConcurrentExecution(timeoutInSeconds: 10 * 60)]
public void SomeMethod()
{
// Operations performed inside a distributed lock
}
My question is: What happens when, given a job which is waiting on obtaining the lock for a DisableConcurrentExecution
-filtered method, the time that the job has been waiting exceeds the timeoutInSeconds
value?
I tested that recently. That job instance was recorded as failed in the dashboard and listed the exception which indicated that the timeout had expired while waiting for an exclusive lock.
You'll see the following exception:
Hangfire.Storage.DistributedLockTimeoutException: Timeout expired. The timeout elapsed prior to obtaining a distributed lock on the 'xxx' resource.
at Hangfire.SqlServer.SqlServerDistributedLock.Acquire(IDbConnection connection, String resource, TimeSpan timeout)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With