Closed rvillane closed 4 years ago
Happens to me as well with same version of mongoose,
This error generally occurs when you lose connectivity to the database. Can you clarify whether you're connecting to a standalone mongodb instance, replica set, sharded cluster, or MongoDB Atlas? And are there any connectivity issues, server resets, etc. around the time when you experience this issue?
Hello, I'm connecting against a mongoDB replica set. Someone peculiar is that multiple apps share the same connection string (using the same kubernetes secret) and they use the same mongoose version and connection settings, however only one of them is getting this error.
Hello, I've experienced the exact same error with Mongoose 5.7.5, that occurs 3 times over the past two weeks in my production env. I connect to Mongo Atlas. The worst thing is that the error trace does not provide any insight about where it happened if it comes to Mongoose, the way I start the driver or elsewhere...
{ MongoError: server instance pool was destroyed
at basicWriteValidations (/app/node_modules/mongodb/lib/core/sdam/server.js:408:12)
at basicReadValidations (/app/node_modules/mongodb/lib/core/sdam/server.js:415:17)
at Server.command (/app/node_modules/mongodb/lib/core/sdam/server.js:237:19)
at checkServer (/app/node_modules/mongodb/lib/core/sdam/monitoring.js:148:12)
at server.s.pool.reset (/app/node_modules/mongodb/lib/core/sdam/monitoring.js:204:7)
at err (/app/node_modules/mongodb/lib/core/connection/pool.js:732:9)
at eachAsync (/app/node_modules/mongodb/lib/core/utils.js:135:5)
at Pool.reset (/app/node_modules/mongodb/lib/core/connection/pool.js:709:3)
at checkServer (/app/node_modules/mongodb/lib/core/sdam/monitoring.js:202:19)
at server.command (/app/node_modules/mongodb/lib/core/sdam/monitoring.js:164:18)
at Server.command (/app/node_modules/mongodb/lib/core/sdam/server.js:239:14)
at checkServer (/app/node_modules/mongodb/lib/core/sdam/monitoring.js:148:12)
at Object.monitorServer [as monitorFunction] (/app/node_modules/mongodb/lib/core/sdam/monitoring.js:193:3)
at Server.monitor (/app/node_modules/mongodb/lib/core/sdam/server.js:216:12)
at Timeout.setTimeout (/app/node_modules/mongodb/lib/core/sdam/topology.js:859:22)
at ontimeout (timers.js:436:11)
at tryOnTimeout (timers.js:300:5)
at listOnTimeout (timers.js:263:5)
I'm not using mongoose, just the raw mongo driver (3.2.2), with Atlas. I do seem to be seeing this a lot in the last couple of weeks. Just in case it's useful.
@antony Did you see that error too?
MongoTimeoutError: Server selection timed out after 30000 ms
at Timeout.setTimeout [as _onTimeout] (/app/node_modules/mongoose/node_modules/mongodb/lib/core/sdam/topology.js:850:16)
at ontimeout (timers.js:436:11)
at tryOnTimeout (timers.js:300:5)
at listOnTimeout (timers.js:263:5)
at Timer.processTimers (timers.js:223:10)
@blasterbug Yeah - that and one about topology sometimes.
Hello, this is happening to me too, the two errors that seem to repeat are:
MongoTimeoutError: Server selection timed out after 30000 ms at Timeout._onTimeout (/app/node_modules/mongodb/lib/core/sdam/topology.js:850:16) at listOnTimeout (internal/timers.js:531:17) at processTimers (internal/timers.js:475:7)
MongoError: server instance pool was destroyed at basicWriteValidations (/app/node_modules/mongodb/lib/core/sdam/server.js:388:12) at basicReadValidations (/app/node_modules/mongodb/lib/core/sdam/server.js:395:17) at Server.command (/app/node_modules/mongodb/lib/core/sdam/server.js:217:19) at checkServer (/app/node_modules/mongodb/lib/core/sdam/monitoring.js:144:12) at /app/node_modules/mongodb/lib/core/sdam/monitoring.js:197:7 at /app/node_modules/mongodb/lib/core/connection/pool.js:788:9 at eachAsync (/app/node_modules/mongodb/lib/core/utils.js:135:5) at Pool.reset (/app/node_modules/mongodb/lib/core/connection/pool.js:765:3) at /app/node_modules/mongodb/lib/core/sdam/monitoring.js:195:19 at /app/node_modules/mongodb/lib/core/sdam/monitoring.js:160:18 at Server.command (/app/node_modules/mongodb/lib/core/sdam/server.js:219:14) at checkServer (/app/node_modules/mongodb/lib/core/sdam/monitoring.js:144:12) at Object.monitorServer [as monitorFunction] (/app/node_modules/mongodb/lib/core/sdam/monitoring.js:186:3) at Server.monitor (/app/node_modules/mongodb/lib/core/sdam/server.js:196:12) at Timeout._onTimeout (/app/node_modules/mongodb/lib/core/sdam/topology.js:827:22) at listOnTimeout (internal/timers.js:531:17)
I have many services connected to the same cluster (on Mongo Atlas) but only one of them get these errors sometimes, a couple of time this month
The only guess I have is that this service is the only one using the useUnifiedTopology
option (since from last mongoose versions there is a warning about that), could that be related?
I have the same issue, will subscribe to this one. Removed the "useUnifiedTopology" for now to check if that will solve it.
Do you want to request a feature or report a bug? Bug
What are the versions of Node.js, Mongoose and MongoDB you are using? Note that "latest" is not a version.
"mongoose": "5.7.1",
What is the current behavior?
I randomly get this error below
the connection code uses these settings:
any recommendations ?
MongoError: server instance pool was destroyed at basicWriteValidations (/dist/node_modules/mongodb/lib/core/sdam/server.js:388:12) at executeWriteOperation (/dist/node_modules/mongodb/lib/core/sdam/server.js:415:17) at Server.insert (/dist/node_modules/mongodb/lib/core/sdam/server.js:337:5) at topology.selectServer (/dist/node_modules/mongodb/lib/core/sdam/topology.js:998:15) at selectServers (/dist/node_modules/mongodb/lib/core/sdam/topology.js:394:9) at selectServers (/dist/node_modules/mongodb/lib/core/sdam/topology.js:816:12) at NativeTopology.selectServer (/dist/node_modules/mongodb/lib/core/sdam/topology.js:381:5) at executeWriteOperation (/dist/node_modules/mongodb/lib/core/sdam/topology.js:966:12) at NativeTopology.insert (/dist/node_modules/mongodb/lib/core/sdam/topology.js:535:5) at NativeTopology.insert (/dist/node_modules/mongodb/lib/topologies/native_topology.js:58:11) at insertDocuments (/dist/node_modules/mongodb/lib/operations/common_functions.js:260:19) at InsertOneOperation.execute (/dist/node_modules/mongodb/lib/operations/insert_one.js:26:5) at executeOperation (/dist/node_modules/mongodb/lib/operations/execute_operation.js:83:26) at Collection.insertOne (/dist/node_modules/mongodb/lib/collection.js:476:10) at NativeCollection.(anonymous function) [as insertOne] (/dist/node_modules/mongoose/lib/drivers/node-mongodb-native/collection.js:166:28) at model.Model.$__handleSave (/dist/node_modules/mongoose/lib/model.js:262:33) at model.Model.$__save (/dist/node_modules/mongoose/lib/model.js:320:8) at /dist/node_modules/kareem/index.js:278:20 at _next (/dist/node_modules/kareem/index.js:102:16) at process.nextTick (/dist/node_modules/kareem/index.js:507:38) at process._tickCallback (internal/process/next_tick.js:61:11)