From 6ff2c1c9ce656aec32e4e264ccf07a742bd9801d Mon Sep 17 00:00:00 2001 From: David Glasser Date: Mon, 21 Oct 2013 18:59:34 -0700 Subject: [PATCH] Set Mongo connection pool size better. Fixes (for now) misordered oplog errors. --- packages/mongo-livedata/mongo_driver.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/packages/mongo-livedata/mongo_driver.js b/packages/mongo-livedata/mongo_driver.js index 79d57128fd..84933c7f6b 100644 --- a/packages/mongo-livedata/mongo_driver.js +++ b/packages/mongo-livedata/mongo_driver.js @@ -113,7 +113,7 @@ MongoConnection = function (url, options) { self._connectCallbacks = []; self._liveResultsSets = {}; - var mongoOptions = {db: {safe: true}, server: {}}; + var mongoOptions = {db: {safe: true}, server: {}, replSet: {}}; // Set autoReconnect to true, unless passed on the URL. Why someone // would want to set autoReconnect to false, I'm not really sure, but @@ -137,7 +137,10 @@ MongoConnection = function (url, options) { // XXX maybe we should have a better way of allowing users to configure the // underlying Mongo driver if (_.has(options, 'poolSize')) { - mongoOptions.server.poolSize = 1; + // If we just set this for "server", replSet will override it. If we just + // set it for replSet, it will be ignored if we're not using a replSet. + mongoOptions.server.poolSize = options.poolSize; + mongoOptions.replSet.poolSize = options.poolSize; } MongoDB.connect(url, mongoOptions, function(err, db) {