Meteor app crash randomly throwing a 'MongoError: server instance pool was destroyed' error

I’ve had a couple of apps go through every update since 1.0 without this issue. Both apps started throwing the error every 10 mins on my local dev machine after I updated them to 1.4.1.2. Note: one app was using the other app’s db (export MONGO_URL='mongodb://localhost:3001/meteor') on my dev machine (Mongo 3.2).

I deployed one of the apps (the one running on port 3000 on my dev machine) to three different production servers (all Ubuntu 16, one using Mongo 3.2 on Compose, another using Mongo 3.2 on the same Ubuntu box, and the third using Mongo 2.6 on the same Ubuntu box). None of these app instances threw the error in the hour or so I left them deployed.

I’ve reverted everything to 1.4.1.1. No errors in production (there weren’t with 1.4.1.2 either) but, importantly, no errors on my local dev machine. (It made development difficult when the server crashed and didn’t recover once every 10 mins.)

Looks like the same issue for me, but not 100% sure as I’m connecting to the Meteor instance locally from a React Native app.

=> App running at: http://localhost:3000/
I20161008-11:41:52.812(-7)? Exception in setInterval callback: MongoError: server instance pool was destroyed
I20161008-11:41:52.812(-7)?     at Object.Future.wait (/Users/jamielob/.meteor/packages/meteor-tool/.1.4.1_2.fnvaxz++os.osx.x86_64+web.browser+web.cordova/mt-os.osx.x86_64/dev_bundle/server-lib/node_modules/fibers/future.js:446:16)
I20161008-11:41:52.812(-7)?     at MongoConnection.<anonymous> (packages/meteor/helpers.js:119:1)
I20161008-11:41:52.813(-7)?     at MongoConnection.(anonymous function) [as update] (packages/mongo/mongo_driver.js:771:49)
I20161008-11:41:52.813(-7)?     at [object Object].update (packages/mongo/collection.js:589:29)
I20161008-11:41:52.813(-7)?     at AccountsServer.Ap._expireTokens (packages/accounts-base/accounts_server.js:1100:14)
I20161008-11:41:52.813(-7)?     at packages/accounts-base/accounts_server.js:1173:14
I20161008-11:41:52.814(-7)?     at [object Object]._.extend.withValue (packages/meteor/dynamics_nodejs.js:56:1)
I20161008-11:41:52.814(-7)?     at packages/meteor/timers.js:6:1
I20161008-11:41:52.814(-7)?     at runWithEnvironment (packages/meteor/dynamics_nodejs.js:110:1)
I20161008-11:41:52.814(-7)?     - - - - -
I20161008-11:41:52.814(-7)?     at Function.MongoError.create (/Users/jamielob/.meteor/packages/npm-mongo/.1.5.50.1f00k6p++os+web.browser+web.cordova/npm/node_modules/mongodb-core/lib/error.js:29:11)
I20161008-11:41:52.814(-7)?     at basicWriteValidations (/Users/jamielob/.meteor/packages/npm-mongo/.1.5.50.1f00k6p++os+web.browser+web.cordova/npm/node_modules/mongodb-core/lib/topologies/server.js:434:51)
I20161008-11:41:52.815(-7)?     at [object Object].Server.update (/Users/jamielob/.meteor/packages/npm-mongo/.1.5.50.1f00k6p++os+web.browser+web.cordova/npm/node_modules/mongodb-core/lib/topologies/server.js:547:16)
I20161008-11:41:52.815(-7)?     at [object Object].Server.update (/Users/jamielob/.meteor/packages/npm-mongo/.1.5.50.1f00k6p++os+web.browser+web.cordova/npm/node_modules/mongodb/lib/server.js:386:17)
I20161008-11:41:52.815(-7)?     at updateDocuments (/Users/jamielob/.meteor/packages/npm-mongo/.1.5.50.1f00k6p++os+web.browser+web.cordova/npm/node_modules/mongodb/lib/collection.js:1041:19)
I20161008-11:41:52.815(-7)?     at [object Object].Collection.update (/Users/jamielob/.meteor/packages/npm-mongo/.1.5.50.1f00k6p++os+web.browser+web.cordova/npm/node_modules/mongodb/lib/collection.js:1080:44)
I20161008-11:41:52.816(-7)?     at MongoConnection._update (packages/mongo/mongo_driver.js:560:18)
I20161008-11:41:52.816(-7)?     at MongoConnection.<anonymous> (packages/meteor/helpers.js:118:1)
I20161008-11:41:52.816(-7)?     at MongoConnection.(anonymous function) [as update] (packages/mongo/mongo_driver.js:771:49)
I20161008-11:41:52.816(-7)?     at [object Object].update (packages/mongo/collection.js:589:29)

Updating to npm-mongo@2.2.10_1 and then updating all dependencies fixed this for me:

meteor update npm-mongo // Check that it takes you to 2.2.x
meteor update --all-packages
2 Likes

Thanks @jamielob

I’m was getting this locally on OSX.

What worked for me was:

meteor update npm-mongo // Check that it takes you to 2.2.x
meteor update  mongo

I tried that, did not work :frowning:

I have no idea if this is related to this issue, but my Meteor app stopped receiving data from MongoDB. Checked the database server, everything was running smoothly, but I didn’t get any response from my Meteor methods which work with data from the database. Only restarting the Meteor instances solved this issue :slightly_frowning_face:.

Just running on the latest patched version.

@XTA - have you had a look at the server logs? That sounds very much like what was happening to my app on my dev machine as soon as I updated to 1.4.1.2 (the latest patch release). After the error, the server didn’t die entirely (you could refresh the browswer and it would still serve the initial html-js-css payload) but the connection to mongo was never reestablished, so no data was flowing.

I can confirm that the fix from @lpgeiger also resolved the issue for me (at least on my dev machine):

My-Laptop:app user$ meteor update npm-mongo
                                                                                
Changes to your project's package version selections from updating package
versions:
                                              
mongo       upgraded from 1.1.12_3 to 1.1.12_4
npm-mongo*  upgraded from 1.5.50 to 2.2.10_1

                                              
* These packages have been updated to new versions that are not backwards
compatible.
My-Laptop:app user$ meteor update mongo
                                                                                
Changes to your project's package version selections from updating package
versions:
                                              
mongo  upgraded from 1.1.12_4 to 1.1.12_5 
2 Likes

@babrahams Yeah correct, the serving of the JS and asset files still worked fine, only Mongo data didn’t flow anymore. Just saw that they’ve released a new npm-mongo version today (I’ve updated yesterday), at the moment everything is working fine after updating.

I’m having the same problem too (Meteor 1.4.1.2 and MongoDB 3.2). Galaxy hosted meteor instances of the exact same app (Accounts with all the defaults as far as token timeouts) connected to a free mlab instance and MongoDB Atlas 3 machine cluster with oplog enabled. The Atlas hosted database seems to have less trouble but still runs into the same problem over the course of a 1-2 days. Bouncing the Atlas connected meteor server seems to recover for 1-2 days before the problem re-occurs. The mlab instance falls down repeatedly and currently won’t restart/reconnect at all. I’m going to try the npm-mongo update next.

Updating npm-mongo and mongo appears to have both instances back up for now for me too.