Unable to Connect to MongoDb on a Fresh Install in an ASP.NET Core (5.0) Web Application
See original GitHub issueUsing the latest libraries from Hangfire.Core
(v1.7.28) and Hangfire.Mongo
(v0.7.28), I am unable to get a connection to my MongoDB database. I’m using the connection string:
mongodb+srv://prd-core-db:*******@prd-us.*****.mongodb.net/core?retryWrites=true&w=majority
The connection string works perfectly for the other aspects of the application, but after adding the nuget packages, configuring the startup.cs class, I get the following error when running the application:
System.InvalidOperationException: Could not complete migration. Never acquired lock within allowed time: 00:01:00. Either another server did not complete the migration or migration was abruptly interrupted. If migration has been interrupted you need to manually delete "Hangfire.migrationLock" and start again.
I’ve tried modifying the MigrationStrategy
and the BackupStrategy
, but doing so does nothing.
Is there a fix to this? Perhaps I need to create a new collection in Mongo (or set of collections with another script)?
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:9 (5 by maintainers)
@gottscj My DatabaseName property is valid - “hangfire”. See attachment - my database name is highlighted. What I’m not understanding is what Hangfire is doing with Mongo on startup. Is Hangfire supposed to create a Collection in the DB? If so, I’m not seeing anything being created during the timeout period. Is there documentation out there that lists what Collections will be created by Hangfire when the initialization is complete? Perhaps I can create those collections beforehand with better luck.
@dotnetallday,
Thanks for submitting. I’ll try to reproduce. Did you try to manually delete the migrationLock entity in the DB? Are you running multiple instances or just one?
Thanks!