Jon Schneider Jon Schneider - 23 days ago 14
C# Question

Hangfire DisableConcurrentExecution: What happens when the timeout expires?

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?

Answer

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.

I'd send you more details but I'm on my phone right now :)

Comments