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.

useUnifiedTopology=true fails when replica node unvailable

See original GitHub issue

Do you want to request a feature or report a bug?

Bug.

What is the current behavior?

If I try and connect with this MongoDB connection URL and useUnifiedTopology=true:

mongodb://user:xxx@mongo0,mongo1,mongo2/app?replicaSet=rs0&authSource=admin&readPreference=primaryPreferred

Mongoose fails with:

{“name”:“MongoNetworkError”,“errorLabels”:[“TransientTransactionError”]}

mongo0 is PRIMARY and is up. mongo1 and mongo2 are down. The mongo db shell successfully connects with this string. So this isn’t BWC behavior?? Tried a few different options to do with read write concern (ex. readConcern=local&w=0&readPrefernce=primary) but still same error.

If I set useUnifiedTopology=false I get an ugly deprecation warning.

(node:1375) DeprecationWarning: current URL string parser is deprecated, and will be removed in a future version. To use the new parser, pass option { useNewUrlParser: true } to MongoClient.connect.

If the current behavior is a bug, please provide the steps to reproduce.

mongoose = require('mongoose');
mongoose.connect(REPLICAS_URL_WITH_UNAVAILABLE_NON_PRIMARIES)

What is the expected behavior?

Connect same way mongo shell does. Don’t deny availability to my HA replica set when the primary is available.

What are the versions of Node.js, Mongoose and MongoDB you are using? Note that “latest” is not a version.

Mongoose: 5.7.1 MongoDB: 4.2.0 Node: v10.16.3

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:2
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
vkarpov15commented, Oct 7, 2019

I opened up an issue with the mongodb driver: https://jira.mongodb.org/browse/NODE-2231 . In the meantime, if this is blocking you, please turn useUnifiedTopology off. I’ll keep this issue open until we get a fix from the mongodb driver team 👍

0reactions
vkarpov15commented, Oct 23, 2019

@esetnik we shipped v5.7.6 2 days ago 👍

Read more comments on GitHub >

github_iconTop Results From Across the Web

[NODE-2332] useUnifiedTopology - replicaset - MongoDB Jira
Queries are being intermittently not properly rejected when there is a network failure, so requests to our app are hanging indefinitely. More details:...
Read more >
Npm mongodb 3.6.3 useUnifiedTopology throws ...
When i updated to mongodb from 3.6.2 to 3.6.3 when i connect to the DB it throws error if useUnifiedTopology is set to...
Read more >
Mongoose connection to replica set not working - Stack Overflow
This configuration works for me in Local MongoDB with a replica set. await mongoose.connect("mongodb://localhost:27017/movieku", ...
Read more >
Failure domains – Acronis Cyber Infrastructure
Host as a failure domain. Under this policy, Acronis Cyber Infrastructure never places more than one data replica per host. So if a...
Read more >
Improving Availability and Site Performance with MongoDB ...
Auto-clustering enables you to create a replica set of your entire database. ... In case the primary node becomes unavailable for any reason, ......
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