mirror of
https://github.com/meteor/meteor.git
synced 2026-05-02 03:01:46 -04:00
Don't use system.replset to check for replset
It requires an unnecessary level of permissions in Mongo 2.6. Instead, use the isMaster command plus parsing the URL. Fixes #2121.
This commit is contained in:
3
packages/mongo/.npm/package/npm-shrinkwrap.json
generated
3
packages/mongo/.npm/package/npm-shrinkwrap.json
generated
@@ -12,6 +12,9 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"mongodb-uri": {
|
||||
"version": "0.9.7"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
var Future = Npm.require('fibers/future');
|
||||
|
||||
OPLOG_COLLECTION = 'oplog.rs';
|
||||
var REPLSET_COLLECTION = 'system.replset';
|
||||
|
||||
// Like Perl's quotemeta: quotes all regexp metacharacters. See
|
||||
// https://github.com/substack/quotemeta/blob/master/index.js
|
||||
@@ -150,6 +149,13 @@ _.extend(OplogHandle.prototype, {
|
||||
},
|
||||
_startTailing: function () {
|
||||
var self = this;
|
||||
// First, make sure that we're talking to the local database.
|
||||
var mongodbUri = Npm.require('mongodb-uri');
|
||||
if (mongodbUri.parse(self._oplogUrl).database !== 'local') {
|
||||
throw Error("$MONGO_OPLOG_URL must be set to the 'local' database of " +
|
||||
"a Mongo replica set");
|
||||
}
|
||||
|
||||
// We make two separate connections to Mongo. The Node Mongo driver
|
||||
// implements a naive round-robin connection pool: each "connection" is a
|
||||
// pool of several (5 by default) TCP connections, and each request is
|
||||
@@ -169,13 +175,17 @@ _.extend(OplogHandle.prototype, {
|
||||
self._oplogLastEntryConnection = new MongoConnection(
|
||||
self._oplogUrl, {poolSize: 1});
|
||||
|
||||
// First, make sure that there actually is a repl set here. If not, oplog
|
||||
// tailing won't ever find anything! (Blocks until the connection is ready.)
|
||||
var replSetInfo = self._oplogLastEntryConnection.findOne(
|
||||
REPLSET_COLLECTION, {});
|
||||
if (!replSetInfo)
|
||||
// Now, make sure that there actually is a repl set here. If not, oplog
|
||||
// tailing won't ever find anything!
|
||||
var f = new Future;
|
||||
self._oplogLastEntryConnection.db.admin().command(
|
||||
{ ismaster: 1 }, f.resolver());
|
||||
var isMasterDoc = f.wait();
|
||||
if (!(isMasterDoc && isMasterDoc.documents && isMasterDoc.documents[0] &&
|
||||
isMasterDoc.documents[0].setName)) {
|
||||
throw Error("$MONGO_OPLOG_URL must be set to the 'local' database of " +
|
||||
"a Mongo replica set");
|
||||
}
|
||||
|
||||
// Find the last oplog entry.
|
||||
var lastOplogEntry = self._oplogLastEntryConnection.findOne(
|
||||
|
||||
@@ -13,7 +13,8 @@ Package.describe({
|
||||
});
|
||||
|
||||
Npm.depends({
|
||||
mongodb: "https://github.com/meteor/node-mongodb-native/tarball/cbd6220ee17c3178d20672b4a1df80f82f97d4c1"
|
||||
mongodb: "https://github.com/meteor/node-mongodb-native/tarball/cbd6220ee17c3178d20672b4a1df80f82f97d4c1",
|
||||
"mongodb-uri": "0.9.7"
|
||||
});
|
||||
|
||||
Npm.strip({
|
||||
|
||||
Reference in New Issue
Block a user