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

Our MongoDB instance is running on a VM in Azure as a single instance. No replica set. Version 3.2.1.

Here is my full list of packages for our project:

accounts-base@1.2.11
accounts-password@1.3.0
allow-deny@1.0.5
angular@1.3.11
angular-meteor-auth@1.0.3
angular-meteor-data@1.3.11
angular-templates@1.0.9
angular:angular@1.5.3_1
angular:angular-animate@1.5.3_1
angular:angular-sanitize@1.5.3_1
angularui:angular-ui-router@0.2.15
autoupdate@1.3.11
babel-compiler@6.9.1
babel-runtime@0.1.11
barbatus:typescript@0.4.1
barbatus:typescript-compiler@0.7.1_1
barbatus:typescript-runtime@0.1.2
base64@1.0.9
benjamine:jsondiffpatch@0.1.38_1
binary-heap@1.0.9
blaze@2.1.9
blaze-tools@1.0.10
boilerplate-generator@1.0.10
caching-compiler@1.1.7
caching-html-compiler@1.0.7
callback-hook@1.0.9
cfs:http-methods@0.0.32
check@1.2.3
civilframe:angular-jade@0.0.3
coffeescript@1.0.17
cosmos:browserify@0.8.4
dburles:mongo-collection-instances@0.3.5
ddp@1.2.5
ddp-client@1.3.1
ddp-common@1.2.6
ddp-rate-limiter@1.0.5
ddp-server@1.3.10
deanius:promise@3.1.3
deps@1.0.12
diff-sequence@1.0.6
ecmascript@0.5.8
ecmascript-runtime@0.3.14
ejson@1.0.12
email@1.1.17
fastclick@1.0.12
geojson-utils@1.0.9
hot-code-push@1.0.4
html-tools@1.0.11
htmljs@1.0.11
http@1.2.9
id-map@1.0.8
johnantoni:meteor-normalize@0.0.1
jquery@1.11.9
kyleking:customizable-bootstrap-stylus@3.6.3
kyleking:customizable-bootstrap-stylus-data@4.0.6
lai:collection-extensions@0.2.1_1
launch-screen@1.0.12
livedata@1.0.18
localstorage@1.0.11
logging@1.1.15
meteor@1.2.17
meteor-base@1.0.4
mgcrea:angular-strap@2.3.7
minifier-css@1.2.14
minifier-js@1.2.14
minifiers@1.1.7
minimongo@1.0.17
mobile-experience@1.0.4
mobile-status-bar@1.0.12
modules@0.7.6
modules-runtime@0.7.6
momentjs:moment@2.15.0
mongo@1.1.12
mongo-id@1.0.5
mquandalle:jade@0.4.9
mquandalle:jade-compiler@0.4.5
npm-bcrypt@0.9.1
npm-mongo@1.5.49
observe-sequence@1.0.12
ordered-dict@1.0.8
pbastowski:angular-babel@1.3.6
percolate:synced-cron@1.3.2
practicalmeteor:chai@2.1.0_1
practicalmeteor:loglevel@1.2.0_2
practicalmeteor:mocha@2.4.5_6
practicalmeteor:mocha-core@1.0.1
practicalmeteor:sinon@1.14.1_2
promise@0.8.7
random@1.0.10
rate-limit@1.0.5
reactive-dict@1.1.8
reactive-var@1.0.10
reload@1.1.10
retry@1.0.8
routepolicy@1.0.11
service-configuration@1.0.10
session@1.1.6
sgi:ui-mask@1.4.7
sha@1.0.8
shell-server@0.2.1
spacebars@1.0.13
spacebars-compiler@1.0.13
srp@1.0.9
standard-minifier-css@1.2.0
standard-minifier-js@1.2.0
stevezhu:lodash@4.15.0
stolinski:stylus-multi@1.4.3
templating@1.2.15
templating-compiler@1.2.15
templating-runtime@1.2.15
templating-tools@1.0.5
tmeasday:test-reporter-helpers@0.2.1
tracker@1.1.0
ui@1.0.12
underscore@1.0.9
urigo:static-html-compiler@0.1.8
url@1.0.10
vishalm:angular-toastr@1.5.0
webapp@1.3.11
webapp-hashing@1.0.9

@tmeasday Thanks for jumping in!!

@tmeasday I am going to come clean here: Just remembered we are using a logging adapter that consumes all console statements and sends them to our ApplicationInsights tracer / exception logs.

So what we maybe seeing is just an error, but we do not get to see an indication of recovery.

Food for thought

@mspi - so you configure and run the mongo instance yourself?

Have you tried manually stopping the mongo instance or killing the network link to see if you can replicate the problem?

@bretth Can you look at tmeasday’s request? I am not in the office today :slight_smile:

@mspi can can definitely run a test for that.

Having the same problem on local dev from time to time when loosing internet connection. Using mLab sandbox for local (no oplog url) development. I believe it has to do with the autoreconnect in the mongo driver (using 1.4.1.1).
THe mongo_url env variable looks like this

mongodb://user:password/dbName?readPreference=primary

Hi @tmeasday, this began happening to me locally, a few times today - see the screenshot attached.

I’m not sure what initiates the error. I’m running on a Macbook and suddenly the fan would start running like crazy and the whole OS would freeze with exceptions of allowing me to click on my browser and code editor. Any OS menus/taskbar would be inaccessible. I was not able to scroll in terminal and that’s the only screenshot I have for now.

It would be interesting to know if it was mongo or meteor that locked up your CPU… Perhaps you could leave a window running top open somewhere on screen and when things crashed you might see :slight_smile:

 Exception in setInterval callback: MongoError: server instance pool was destroyed
     at Object.Future.wait (/Users/fabien/.meteor/packages/meteor-tool/.1.4.1_2.1jlej5l++os.osx.x86_64+web.browser+web.cordova/mt-os.osx.x86_64/dev_bundle/server-lib/node_modules/fibers/future.js:446:16)
     at MongoConnection.<anonymous> (packages/meteor/helpers.js:119:1)
     at MongoConnection.(anonymous function) [as remove] (packages/mongo/mongo_driver.js:771:49)
     at [object Object].remove (packages/mongo/collection.js:624:29)
     at _cleanStaleResults (packages/oauth/pending_credentials.js:30:1)
     at [object Object]._.extend.withValue (packages/meteor/dynamics_nodejs.js:56:1)
     at packages/meteor/timers.js:6:1
     at runWithEnvironment (packages/meteor/dynamics_nodejs.js:110:1)
     - - - - -
     at Function.MongoError.create (/Users/fabien/.meteor/packages/npm-mongo/.1.5.50.126i5ny++os+web.browser+web.cordova/npm/node_modules/mongodb-core/lib/error.js:29:11)
     at basicWriteValidations (/Users/fabien/.meteor/packages/npm-mongo/.1.5.50.126i5ny++os+web.browser+web.cordova/npm/node_modules/mongodb-core/lib/topologies/server.js:434:51)
     at [object Object].Server.remove (/Users/fabien/.meteor/packages/npm-mongo/.1.5.50.126i5ny++os+web.browser+web.cordova/npm/node_modules/mongodb-core/lib/topologies/server.js:578:16)
     at [object Object].Server.remove (/Users/fabien/.meteor/packages/npm-mongo/.1.5.50.126i5ny++os+web.browser+web.cordova/npm/node_modules/mongodb/lib/server.js:393:17)
     at removeDocuments (/Users/fabien/.meteor/packages/npm-mongo/.1.5.50.126i5ny++os+web.browser+web.cordova/npm/node_modules/mongodb/lib/collection.js:1232:19)
     at [object Object].Collection.remove (/Users/fabien/.meteor/packages/npm-mongo/.1.5.50.126i5ny++os+web.browser+web.cordova/npm/node_modules/mongodb/lib/collection.js:1272:44)
     at MongoConnection._remove (packages/mongo/mongo_driver.js:417:16)
     at MongoConnection.<anonymous> (packages/meteor/helpers.js:118:1)
     at MongoConnection.(anonymous function) [as remove] (packages/mongo/mongo_driver.js:771:49)
     at [object Object].remove (packages/mongo/collection.js:624:29)

Same Error here. Happening since today. Rolled back to 1.4.1 and it seems to work for now.

[Edit] : No it does not :frowning:

I did nothing special for the config.

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.