diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/mongo/db/cloner.cpp | 12 | ||||
-rw-r--r-- | src/mongo/db/commands/create_indexes.cpp | 3 | ||||
-rw-r--r-- | src/mongo/db/commands/write_commands/batch_executor.cpp | 4 | ||||
-rw-r--r-- | src/mongo/db/instance.cpp | 8 | ||||
-rw-r--r-- | src/mongo/s/d_migrate.cpp | 17 |
5 files changed, 35 insertions, 9 deletions
diff --git a/src/mongo/db/cloner.cpp b/src/mongo/db/cloner.cpp index 5c4fe93d63a..d28fd763923 100644 --- a/src/mongo/db/cloner.cpp +++ b/src/mongo/db/cloner.cpp @@ -128,6 +128,12 @@ namespace mongo { createdCollection = true; collection = db->createCollection( txn, to_collection.ns() ); verify( collection ); + if (logForRepl) { + repl::logOp(txn, + "c", + (_dbName + ".$cmd").c_str(), + BSON("create" << to_collection.coll())); + } wunit.commit(); } @@ -258,6 +264,12 @@ namespace mongo { WriteUnitOfWork wunit(txn); collection = db->createCollection( txn, to_collection.ns() ); invariant(collection); + if (logForRepl) { + repl::logOp(txn, + "c", + (toDBName + ".$cmd").c_str(), + BSON("create" << to_collection.coll())); + } wunit.commit(); } diff --git a/src/mongo/db/commands/create_indexes.cpp b/src/mongo/db/commands/create_indexes.cpp index 3b9af7bc48d..4b5c1a869ba 100644 --- a/src/mongo/db/commands/create_indexes.cpp +++ b/src/mongo/db/commands/create_indexes.cpp @@ -144,6 +144,9 @@ namespace mongo { WriteUnitOfWork wunit(txn); collection = db->createCollection( txn, ns.ns() ); invariant( collection ); + if (!fromRepl) { + repl::logOp(txn, "c", (dbname + ".$cmd").c_str(), BSON("create" << ns.coll())); + } wunit.commit(); } diff --git a/src/mongo/db/commands/write_commands/batch_executor.cpp b/src/mongo/db/commands/write_commands/batch_executor.cpp index e73e06efcb6..452c8155b52 100644 --- a/src/mongo/db/commands/write_commands/batch_executor.cpp +++ b/src/mongo/db/commands/write_commands/batch_executor.cpp @@ -942,6 +942,10 @@ namespace mongo { request->getTargetingNS()))); return false; } + repl::logOp(txn, + "c", + (database->name() + ".$cmd").c_str(), + BSON("create" << nsToCollectionSubstring(request->getTargetingNS()))); wunit.commit(); } return true; diff --git a/src/mongo/db/instance.cpp b/src/mongo/db/instance.cpp index b5886eb5e58..c0da7ea2fc1 100644 --- a/src/mongo/db/instance.cpp +++ b/src/mongo/db/instance.cpp @@ -798,6 +798,10 @@ namespace mongo { WriteUnitOfWork wunit(txn); collection = ctx.db()->createCollection( txn, targetNS ); verify( collection ); + repl::logOp(txn, + "c", + (ctx.db()->name() + ".$cmd").c_str(), + BSON("create" << nsToCollectionSubstring(targetNS))); wunit.commit(); } @@ -838,6 +842,10 @@ namespace mongo { if ( !collection ) { collection = ctx.db()->createCollection( txn, ns ); verify( collection ); + repl::logOp(txn, + "c", + (ctx.db()->name() + ".$cmd").c_str(), + BSON("create" << nsToCollectionSubstring(ns))); } StatusWith<DiskLoc> status = collection->insertDocument( txn, js, true ); diff --git a/src/mongo/s/d_migrate.cpp b/src/mongo/s/d_migrate.cpp index f0c86759a29..9d7bf98e7e4 100644 --- a/src/mongo/s/d_migrate.cpp +++ b/src/mongo/s/d_migrate.cpp @@ -1685,15 +1685,14 @@ namespace mongo { if ( !collection ) { string system_namespaces = nsToDatabase(ns) + ".system.namespaces"; BSONObj entry = conn->findOne( system_namespaces, BSON( "name" << ns ) ); - if ( entry["options"].isABSONObj() ) { - Status status = userCreateNS( txn, db, ns, entry["options"].Obj(), true, 0 ); - if ( !status.isOK() ) { - warning() << "failed to create collection [" << ns << "] " - << " with options: " << status; - } - } - else { - db->createCollection( txn, ns ); + BSONObj options; + if ( entry["options"].isABSONObj() ) + options = entry["options"].Obj(); + + Status status = userCreateNS( txn, db, ns, options, true, false ); + if ( !status.isOK() ) { + warning() << "failed to create collection [" << ns << "] " + << " with options " << options << ": " << status; } } ctx.commit(); |