diff options
author | Martin Bligh <mbligh@mongodb.com> | 2015-10-21 13:25:24 -0400 |
---|---|---|
committer | Martin Bligh <mbligh@mongodb.com> | 2015-10-21 13:26:52 -0400 |
commit | a46d64143bae5b1e66b18cb13683d59d8d986e6b (patch) | |
tree | 73da57b8ad77f1b466f45e684f1d98fb56636e05 | |
parent | f7f592e92b3146e20d311a35492116d7488e7e2b (diff) | |
download | mongo-a46d64143bae5b1e66b18cb13683d59d8d986e6b.tar.gz |
SERVER-21048: Stop regetting the collection in deleteObjects
-rw-r--r-- | src/mongo/db/dbhelpers.cpp | 3 | ||||
-rw-r--r-- | src/mongo/db/ops/delete.cpp | 7 | ||||
-rw-r--r-- | src/mongo/db/ops/delete.h | 2 | ||||
-rw-r--r-- | src/mongo/db/repl/oplog.cpp | 2 | ||||
-rw-r--r-- | src/mongo/db/repl/rs_rollback.cpp | 2 | ||||
-rw-r--r-- | src/mongo/db/s/migration_destination_manager.cpp | 2 |
6 files changed, 7 insertions, 11 deletions
diff --git a/src/mongo/db/dbhelpers.cpp b/src/mongo/db/dbhelpers.cpp index 8f970c8ca11..999a2c8250e 100644 --- a/src/mongo/db/dbhelpers.cpp +++ b/src/mongo/db/dbhelpers.cpp @@ -562,7 +562,8 @@ void Helpers::emptyCollection(OperationContext* txn, const char* ns) { bool shouldReplicateWrites = txn->writesAreReplicated(); txn->setReplicatedWrites(false); ON_BLOCK_EXIT(&OperationContext::setReplicatedWrites, txn, shouldReplicateWrites); - deleteObjects(txn, context.db(), ns, BSONObj(), PlanExecutor::YIELD_MANUAL, false); + Collection* collection = context.db() ? context.db()->getCollection(ns) : nullptr; + deleteObjects(txn, collection, ns, BSONObj(), PlanExecutor::YIELD_MANUAL, false); } Helpers::RemoveSaver::RemoveSaver(const string& a, const string& b, const string& why) { diff --git a/src/mongo/db/ops/delete.cpp b/src/mongo/db/ops/delete.cpp index 325b0d36bc0..870deb66dd5 100644 --- a/src/mongo/db/ops/delete.cpp +++ b/src/mongo/db/ops/delete.cpp @@ -45,7 +45,7 @@ namespace mongo { god: allow access to system namespaces, and don't yield */ long long deleteObjects(OperationContext* txn, - Database* db, + Collection* collection, StringData ns, BSONObj pattern, PlanExecutor::YieldPolicy policy, @@ -60,11 +60,6 @@ long long deleteObjects(OperationContext* txn, request.setFromMigrate(fromMigrate); request.setYieldPolicy(policy); - Collection* collection = NULL; - if (db) { - collection = db->getCollection(nsString.ns()); - } - ParsedDelete parsedDelete(txn, &request); uassertStatusOK(parsedDelete.parseRequest()); diff --git a/src/mongo/db/ops/delete.h b/src/mongo/db/ops/delete.h index b4b7345d70b..f45a2674cb4 100644 --- a/src/mongo/db/ops/delete.h +++ b/src/mongo/db/ops/delete.h @@ -40,7 +40,7 @@ class Database; class OperationContext; long long deleteObjects(OperationContext* txn, - Database* db, + Collection* collection, StringData ns, BSONObj pattern, PlanExecutor::YieldPolicy policy, diff --git a/src/mongo/db/repl/oplog.cpp b/src/mongo/db/repl/oplog.cpp index 7c39b27b828..485e5fd386b 100644 --- a/src/mongo/db/repl/oplog.cpp +++ b/src/mongo/db/repl/oplog.cpp @@ -830,7 +830,7 @@ Status applyOperation_inlock(OperationContext* txn, o.hasField("_id")); if (opType[1] == 0) { - deleteObjects(txn, db, ns, o, PlanExecutor::YIELD_MANUAL, /*justOne*/ valueB); + deleteObjects(txn, collection, ns, o, PlanExecutor::YIELD_MANUAL, /*justOne*/ valueB); } else verify(opType[1] == 'b'); // "db" advertisement } else if (*opType == 'n') { diff --git a/src/mongo/db/repl/rs_rollback.cpp b/src/mongo/db/repl/rs_rollback.cpp index 38b122d745b..b2a7269796a 100644 --- a/src/mongo/db/repl/rs_rollback.cpp +++ b/src/mongo/db/repl/rs_rollback.cpp @@ -687,7 +687,7 @@ void syncFixUp(OperationContext* txn, } } else { deleteObjects(txn, - ctx.db(), + collection, doc.ns, pattern, PlanExecutor::YIELD_MANUAL, diff --git a/src/mongo/db/s/migration_destination_manager.cpp b/src/mongo/db/s/migration_destination_manager.cpp index d5f5517511d..f9746f2b214 100644 --- a/src/mongo/db/s/migration_destination_manager.cpp +++ b/src/mongo/db/s/migration_destination_manager.cpp @@ -836,7 +836,7 @@ bool MigrationDestinationManager::_applyMigrateOp(OperationContext* txn, } deleteObjects(txn, - ctx.db(), + ctx.db() ? ctx.db()->getCollection(ns) : nullptr, ns, id, PlanExecutor::YIELD_MANUAL, |