useUnifiedTopology=true fails when replica node unvailable
See original GitHub issueDo 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:
- Created 4 years ago
- Reactions:2
- Comments:8 (3 by maintainers)
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 👍@esetnik we shipped v5.7.6 2 days ago 👍