question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Hangfire.Mongo.DistributedLock.MongoDistributedLockException: Could not release a lock on the resource 'HangFire:locks:schedulepoller'

See original GitHub issue

Hi, I got this error using Hangfire.Mongo drive.

Environment:

  • Win. Server 2012;
  • 3 nodes of MongoDB with replication set;
  • Hangfire.Pro: 1.4.7.0;
  • Hangfire.Core: 1.6.8.0;
  • Hangfire.Mongo: 0.3.2.201;

1000 jobs are executed every 15 min and 7 jobs at a time.


Message: Hangfire.Mongo.DistributedLock.MongoDistributedLockException: Could not release a lock on the resource ‘HangFire:locks:schedulepoller’: Check inner exception for details. System.UnauthorizedAccessException: Access to the path is denied.

Exception:

   at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
   at System.Threading.EventWaitHandle.OpenExistingWorker(String name, EventWaitHandleRights rights, EventWaitHandle& result)
   at Hangfire.Mongo.DistributedLock.MongoDistributedLock.Release()
   --- End of inner exception stack trace ---
   at Hangfire.Mongo.DistributedLock.MongoDistributedLock.Release()
   at Hangfire.Mongo.DistributedLock.MongoDistributedLock.Dispose()
   at Hangfire.Server.DelayedJobScheduler.EnqueueNextScheduledJob(BackgroundProcessContext context)
   at Hangfire.Server.DelayedJobScheduler.Execute(BackgroundProcessContext context)
   at Hangfire.Server.AutomaticRetryProcess.Execute(BackgroundProcessContext context)

I think the error happens in this line: https://github.com/sergeyzwezdin/Hangfire.Mongo/blob/master/src/Hangfire.Mongo/DistributedLock/MongoDistributedLock.cs#L209

Someone had the same problem? Is there any solution for this?

Thanks.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:1
  • Comments:20 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
provanguardcommented, Jun 12, 2019

In Hangfire configuration:

var mongoclient = (IMongoClient)app.ApplicationServices.GetRequiredService(typeof(IMongoClient));
GlobalConfiguration.Configuration.UseMongoStorage(mongoclient.Settings, Settings.Database.DatabaseName, storageOptions);

In Mongo settings:

services.AddSingleton<IMongoClient>(provider =>
            {
                var settings = MongoClientSettings.FromUrl(MongoUrl.Create(Settings.Database.ConnectionString));
                settings.MaxConnectionPoolSize = 200;
                settings.MaxConnectionIdleTime = TimeSpan.FromMinutes(1);
                settings.ConnectTimeout = TimeSpan.FromSeconds(55);
                settings.SocketTimeout = TimeSpan.FromSeconds(55);
                return new MongoClient(settings);
            });
1reaction
provanguardcommented, Nov 22, 2018

@gottscj The errors I pasted above got solved after configuring more properties on the mongo repository client and the C# driver. Thanks for help!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Hangfire.Mongo.DistributedLock ...
MongoDistributedLockException: Could not release a lock on the resource 'HangFire:locks:schedulepoller': Check inner exception for details.
Read more >
Lock timeout problems! - question
Started seeing a lot of errors on my staging deployment. Could not place a lock on the resource 'HangFire:locks:schedulepoller' and ...
Read more >
Getting Hangfire to use MongoDB Storage
I've verified the database exists and the above connection string is correct. I get this exception: Unable to clean up locks on the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found