From e9d175a86c4e7edd99a4e09b4095f6ce43f40440 Mon Sep 17 00:00:00 2001 From: Dwight Merriman Date: Sun, 30 May 2010 15:04:20 -0400 Subject: [PATCH] tweak to _logOp() teeny bit faster --- db/oplog.cpp | 11 ++++++----- db/repl.cpp | 6 +++++- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/db/oplog.cpp b/db/oplog.cpp index 3f4a2e942a1..919d977d641 100644 --- a/db/oplog.cpp +++ b/db/oplog.cpp @@ -26,7 +26,7 @@ namespace mongo { int __findingStartInitialTimeout = 5; // configurable for testing - // cached copies of these...so don't rename them + // cached copies of these...so don't rename them, drop them, etc.!!! NamespaceDetails *localOplogMainDetails = 0; Database *localOplogDB = 0; @@ -45,7 +45,7 @@ namespace mongo { "c" db cmd "db" declares presence of a database (ns is set to the db name + '.') "n" no op - logNS - e.g. "local.oplog.$main" + logNS - where to log it. 0/null means "local.oplog.$main". bb: if not null, specifies a boolean to pass along to the other side as b: param. used for "justOne" or "upsert" flags on 'd', 'u' @@ -85,7 +85,8 @@ namespace mongo { int len = posz + obj.objsize() + 1 + 2 /*o:*/; Record *r; - if ( strncmp( logNS, "local.", 6 ) == 0 ) { // For now, assume this is olog main + if( logNS == 0 ) { + logNS = "local.oplog.$main"; if ( localOplogMainDetails == 0 ) { Client::Context ctx("local.", dbpath, 0, false); localOplogDB = ctx.db(); @@ -120,12 +121,12 @@ namespace mongo { void logKeepalive() { BSONObj obj; - _logOp("n", "", "local.oplog.$main", obj, 0, 0); + _logOp("n", "", 0, obj, 0, 0); } void logOp(const char *opstr, const char *ns, const BSONObj& obj, BSONObj *patt, bool *b) { if ( replSettings.master ) { - _logOp(opstr, ns, "local.oplog.$main", obj, patt, b); + _logOp(opstr, ns, 0, obj, patt, b); // why? : //char cl[ 256 ]; //nsToDatabase( ns, cl ); diff --git a/db/repl.cpp b/db/repl.cpp index 5a848c176b3..db3c6d08a92 100644 --- a/db/repl.cpp +++ b/db/repl.cpp @@ -1732,8 +1732,12 @@ namespace mongo { void startReplication() { /* if we are going to be a replica set, we aren't doing other forms of replication. */ - if( !cmdLine.replSet.empty() ) + if( !cmdLine.replSet.empty() ) { + if( replSettings.slave || replSettings.master || replPair ) { + log() << "ERROR: can't use --slave or --master replication options with --replSet" << endl; + } return; + } /* this was just to see if anything locks for longer than it should -- we need to be careful not to be locked when trying to connect() or query() the other side.