New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uncaught exception MongoServerSelectionError during primary node election #11661
Comments
Not sure how to create a repro script since my only way to repro is to perform a Test Failover in Mongo Atlas. All you need is a local Node.js process running with an opened connection to the database to see the issue. |
Die you try Mongoose 6.3? We updated the Mongodb native Driver. Maybe they fixed the issue? |
I'll try that out! |
After updating to mongoose |
@francescov1 seeing the 'disconnected' event during re-election is expected. The unhandled 'error' is not expected, but that looks fixed. The 'disconnected' event is purely for debugging and monitoring. It doesn't necessarily mean that Mongoose can't talk to any members in the replica set or execute any operations. It just means that Mongoose lost connectivity to the replica set primary, which is expected during replica set failover. As long as your replica set failover happens quickly (faster than |
@vkarpov15 Thanks for the thorough explanation, this is great to hear 🙌 |
Do you want to request a feature or report a bug?
Report a bug
What is the current behavior?
We are currently running a MongoDB Atlas replica set. We are finding that when our cluster needs to re-elect a new primary, our application loses connection to MongoDB, regains connection, then throws an uncaught exception
MongoServerSelectionError: The server is in quiesce mode and will shut down
.If the current behavior is a bug, please provide the steps to reproduce.
Here is the code we use for connecting:
The error can be reproduced using the Test Failover option in Atlas or by scaling the cluster up or down. When doing this, here are the logs we see:
What is the expected behavior?
mongoose.connection.on('error', ...)
listener.What are the versions of Node.js, Mongoose and MongoDB you are using? Note that "latest" is not a version.
Node.js: 16.8
Mongoose: 6.1.6
MongoDB: 5.0
The text was updated successfully, but these errors were encountered: