summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMathias Stearn <mathias@10gen.com>2014-05-19 13:08:47 -0400
committerMathias Stearn <redbeard0531@gmail.com>2014-05-21 15:43:33 -0400
commit7c75cf1da8fe396eb0fff8dc9c7365e539ece611 (patch)
tree470544af989a1b8d82a0ba5f61a0a3976a10a480
parent384e8e322958bdfb8f9932784c8a9d378dc3a425 (diff)
downloadmongo-7c75cf1da8fe396eb0fff8dc9c7365e539ece611.tar.gz
SERVER-13981 MR inc collection should not be replicated
Introduced in commit 8416afb7c5724076b1231626f27f5198a5a2cce7. Prior to that, the collection was not replicated. (cherry picked from commit 65ca787cfe1c287641cd859a8c7cae9e6cbde7f0)
-rw-r--r--src/mongo/db/commands/mr.cpp18
1 files changed, 5 insertions, 13 deletions
diff --git a/src/mongo/db/commands/mr.cpp b/src/mongo/db/commands/mr.cpp
index 4f0001f1db4..752bcfc0d88 100644
--- a/src/mongo/db/commands/mr.cpp
+++ b/src/mongo/db/commands/mr.cpp
@@ -323,6 +323,8 @@ namespace mongo {
// Always forget about temporary namespaces, so we don't cache lots of them
ShardConnection::forgetNS( _config.tempNamespace );
if (_useIncremental) {
+ // NOTE: this will log the deletion of the inc collection which is unnecessary, but
+ // harmless.
_db.dropCollection(_config.incLong);
ShardConnection::forgetNS( _config.incLong );
}
@@ -339,6 +341,7 @@ namespace mongo {
dropTempCollections();
if (_useIncremental) {
// Create the inc collection and make sure we have index on "0" key.
+ // Intentionally not replicating the inc collection to secondaries.
Client::WriteContext incCtx( _config.incLong );
Collection* incColl = incCtx.ctx().db()->getCollection( _config.incLong );
if ( !incColl ) {
@@ -346,21 +349,11 @@ namespace mongo {
options.setNoIdIndex();
options.temp = true;
incColl = incCtx.ctx().db()->createCollection( _config.incLong, options );
-
- // Log the createCollection operation.
- BSONObjBuilder b;
- b.append( "create", nsToCollectionSubstring( _config.incLong ));
- b.appendElements( options.toBSON() );
- string logNs = nsToDatabase( _config.incLong ) + ".$cmd";
- logOp( "c", logNs.c_str(), b.obj() );
}
BSONObj indexSpec = BSON( "key" << BSON( "0" << 1 ) << "ns" << _config.incLong
<< "name" << "_temp_0" );
Status status = incColl->getIndexCatalog()->createIndex( indexSpec, false );
- // Log the createIndex operation.
- string logNs = nsToDatabase( _config.incLong ) + ".system.indexes";
- logOp( "i", logNs.c_str(), indexSpec );
if ( !status.isOK() ) {
uasserted( 17305 , str::stream() << "createIndex failed for mr incLong ns: " <<
_config.incLong << " err: " << status.code() );
@@ -619,7 +612,7 @@ namespace mongo {
}
/**
- * Insert doc in collection
+ * Insert doc in collection. This should be replicated.
*/
void State::insert( const string& ns , const BSONObj& o ) {
verify( _onDisk );
@@ -645,7 +638,7 @@ namespace mongo {
}
/**
- * Insert doc into the inc collection
+ * Insert doc into the inc collection. This should not be replicated.
*/
void State::_insertToInc( BSONObj& o ) {
verify( _onDisk );
@@ -658,7 +651,6 @@ namespace mongo {
" collection expected: " << _config.incLong );
coll->insertDocument( o, true );
- logOp( "i", _config.incLong.c_str(), o );
getDur().commitIfNeeded();
}