marcoCasamento / Hangfire.Redis.StackExchange

HangFire Redis storage based on original (and now unsupported) Hangfire.Redis but using lovely StackExchange.Redis client
Other
460 stars 109 forks source link

The timeout elapsed prior to obtaining a distributed lock #136

Closed MostafaSDesoky closed 5 months ago

MostafaSDesoky commented 8 months ago

Hello I've a problem and unfortunately I have no idea why the error Timeout expired. The timeout elapsed prior to obtaining a distributed lock on the 'Failed to acquire lock on Tahrir_Hangfire_Prod_2lock:recurring-job:Auto Create within given timeout (00:00:15)' resource.

the full error in Event Viewer hit unexpected managed exception, exception code = '0xe0434352'. First 30KB characters of captured stdout and stderr logs: Unhandled exception. Hangfire.Storage.DistributedLockTimeoutException: Timeout expired. The timeout elapsed prior to obtaining a distributed lock on the 'Failed to acquire lock on Tahrir_Hangfire_Prod_2lock:recurring-job:Auto Create within given timeout (00:00:15)' resource. at Hangfire.Redis.RedisLock.Acquire(IDatabase redis, RedisKey key, TimeSpan timeOut, TimeSpan holdDuration) at Hangfire.Redis.RedisLock.Acquire(IDatabase redis, RedisKey key, TimeSpan timeOut) at Hangfire.Redis.RedisConnection.AcquireDistributedLock(String resource, TimeSpan timeout) at Hangfire.RecurringJobExtensions.AcquireDistributedRecurringJobLock(IStorageConnection connection, String recurringJobId, TimeSpan timeout) at Hangfire.RecurringJobManager.AddOrUpdate(String recurringJobId, Job job, String cronExpression, RecurringJobOptions options) at Hangfire.RecurringJob.AddOrUpdate(String recurringJobId, Expression1 methodCall, String cronExpression, RecurringJobOptions options) at Hangfire.RecurringJob.AddOrUpdate(String recurringJobId, Expression1 methodCall, String cronExpression) at Tayar.API.Config.HangfireSetup.Seed(IConfiguration Configuration) at Tayar.API.Config.HangfireSetup.UseCustomConfig(IApplicationBuilder app, IConfiguration Configuration) at Program.<Main>$(String[] args)

the real problem is it shutsdown the application I've searched about timeout and what could be the problem didn't manage to get a good solution thanks in advance

marcoCasamento commented 6 months ago

For some reason that lock can't be taken. Is there maybe another instance that is trying to add exactly tha same recurring job ? As per the application crash, the library don't have enough visibility to decide to wrap the error, avoiding the crash. It have to be wrapped somewhere else up in the stack

marcoCasamento commented 5 months ago

closing as for no response from OP