summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/mongo/db/catalog/cursor_manager.cpp5
-rw-r--r--src/mongo/db/commands/dbcommands.cpp2
-rw-r--r--src/mongo/db/commands/distinct.cpp1
-rw-r--r--src/mongo/db/commands/group_cmd.cpp1
-rw-r--r--src/mongo/db/commands/haystack.cpp3
-rw-r--r--src/mongo/db/commands/index_filter_commands.cpp5
-rw-r--r--src/mongo/db/commands/mr.cpp182
-rw-r--r--src/mongo/db/commands/mr.h13
-rw-r--r--src/mongo/db/commands/mr_common.cpp2
-rw-r--r--src/mongo/db/commands/mr_test.cpp7
-rw-r--r--src/mongo/db/commands/parallel_collection_scan.cpp3
-rw-r--r--src/mongo/db/commands/plan_cache_commands.cpp7
-rw-r--r--src/mongo/db/commands/repair_cursor.cpp3
-rw-r--r--src/mongo/db/db_raii.h7
-rw-r--r--src/mongo/db/dbhelpers.cpp32
-rw-r--r--src/mongo/db/namespace_string.h4
-rw-r--r--src/mongo/db/pipeline/pipeline_d.cpp3
-rw-r--r--src/mongo/db/repl/master_slave.cpp3
-rw-r--r--src/mongo/db/repl/oplog.cpp2
-rw-r--r--src/mongo/db/repl/replication_info.cpp5
-rw-r--r--src/mongo/db/repl/rs_rollback_test.cpp3
-rw-r--r--src/mongo/db/repl/sync_tail.cpp2
-rw-r--r--src/mongo/dbtests/plan_ranking.cpp3
-rw-r--r--src/mongo/dbtests/query_plan_executor.cpp9
-rw-r--r--src/mongo/dbtests/query_stage_cached_plan.cpp5
-rw-r--r--src/mongo/dbtests/query_stage_collscan.cpp27
-rw-r--r--src/mongo/dbtests/query_stage_distinct.cpp19
-rw-r--r--src/mongo/dbtests/query_stage_multiplan.cpp9
-rw-r--r--src/mongo/dbtests/query_stage_tests.cpp5
-rw-r--r--src/mongo/dbtests/query_stage_update.cpp5
-rw-r--r--src/mongo/dbtests/querytests.cpp9
31 files changed, 196 insertions, 190 deletions
diff --git a/src/mongo/db/catalog/cursor_manager.cpp b/src/mongo/db/catalog/cursor_manager.cpp
index 58b1cb73c2e..8640229faa9 100644
--- a/src/mongo/db/catalog/cursor_manager.cpp
+++ b/src/mongo/db/catalog/cursor_manager.cpp
@@ -40,6 +40,7 @@
#include "mongo/db/catalog/database_holder.h"
#include "mongo/db/client.h"
#include "mongo/db/db_raii.h"
+#include "mongo/db/namespace_string.h"
#include "mongo/db/operation_context.h"
#include "mongo/db/query/plan_executor.h"
#include "mongo/db/service_context.h"
@@ -264,9 +265,7 @@ std::size_t GlobalCursorIdCache::timeoutCursors(OperationContext* txn, int milli
// For each collection, time out its cursors under the collection lock (to prevent the
// collection from going away during the erase).
for (unsigned i = 0; i < todo.size(); i++) {
- const std::string& ns = todo[i];
-
- AutoGetCollectionOrViewForRead ctx(txn, ns);
+ AutoGetCollectionOrViewForRead ctx(txn, NamespaceString(todo[i]));
if (!ctx.getDb()) {
continue;
}
diff --git a/src/mongo/db/commands/dbcommands.cpp b/src/mongo/db/commands/dbcommands.cpp
index 7695eefe007..64b0d3e2b11 100644
--- a/src/mongo/db/commands/dbcommands.cpp
+++ b/src/mongo/db/commands/dbcommands.cpp
@@ -892,7 +892,7 @@ public:
BSONObj keyPattern = jsobj.getObjectField("keyPattern");
bool estimate = jsobj["estimate"].trueValue();
- AutoGetCollectionForRead ctx(txn, ns);
+ AutoGetCollectionForRead ctx(txn, NamespaceString(ns));
Collection* collection = ctx.getCollection();
long long numRecords = 0;
diff --git a/src/mongo/db/commands/distinct.cpp b/src/mongo/db/commands/distinct.cpp
index 1b129780fa7..ed2c03d6dad 100644
--- a/src/mongo/db/commands/distinct.cpp
+++ b/src/mongo/db/commands/distinct.cpp
@@ -49,6 +49,7 @@
#include "mongo/db/exec/working_set_common.h"
#include "mongo/db/jsobj.h"
#include "mongo/db/matcher/extensions_callback_real.h"
+#include "mongo/db/namespace_string.h"
#include "mongo/db/query/cursor_response.h"
#include "mongo/db/query/explain.h"
#include "mongo/db/query/find_common.h"
diff --git a/src/mongo/db/commands/group_cmd.cpp b/src/mongo/db/commands/group_cmd.cpp
index 0df1c64d113..71f9bdbd408 100644
--- a/src/mongo/db/commands/group_cmd.cpp
+++ b/src/mongo/db/commands/group_cmd.cpp
@@ -41,6 +41,7 @@
#include "mongo/db/db_raii.h"
#include "mongo/db/exec/group.h"
#include "mongo/db/exec/working_set_common.h"
+#include "mongo/db/namespace_string.h"
#include "mongo/db/query/find_common.h"
#include "mongo/db/query/get_executor.h"
#include "mongo/db/query/plan_summary_stats.h"
diff --git a/src/mongo/db/commands/haystack.cpp b/src/mongo/db/commands/haystack.cpp
index e4010b2ff1d..dc44fef0e1d 100644
--- a/src/mongo/db/commands/haystack.cpp
+++ b/src/mongo/db/commands/haystack.cpp
@@ -43,6 +43,7 @@
#include "mongo/db/index/index_descriptor.h"
#include "mongo/db/index_names.h"
#include "mongo/db/jsobj.h"
+#include "mongo/db/namespace_string.h"
#include "mongo/db/query/find_common.h"
/**
@@ -102,7 +103,7 @@ public:
BSONObjBuilder& result) {
const NamespaceString nss = parseNsCollectionRequired(dbname, cmdObj);
- AutoGetCollectionForRead ctx(txn, nss.ns());
+ AutoGetCollectionForRead ctx(txn, nss);
Collection* collection = ctx.getCollection();
if (!collection) {
diff --git a/src/mongo/db/commands/index_filter_commands.cpp b/src/mongo/db/commands/index_filter_commands.cpp
index a591d48491c..3ec63ba635c 100644
--- a/src/mongo/db/commands/index_filter_commands.cpp
+++ b/src/mongo/db/commands/index_filter_commands.cpp
@@ -47,6 +47,7 @@
#include "mongo/db/jsobj.h"
#include "mongo/db/matcher/expression_parser.h"
#include "mongo/db/matcher/extensions_callback_real.h"
+#include "mongo/db/namespace_string.h"
#include "mongo/stdx/unordered_set.h"
#include "mongo/util/log.h"
@@ -164,7 +165,7 @@ Status ListFilters::runIndexFilterCommand(OperationContext* txn,
BSONObj& cmdObj,
BSONObjBuilder* bob) {
// This is a read lock. The query settings is owned by the collection.
- AutoGetCollectionForRead ctx(txn, ns);
+ AutoGetCollectionForRead ctx(txn, NamespaceString(ns));
QuerySettings* querySettings;
PlanCache* unused;
@@ -232,7 +233,7 @@ Status ClearFilters::runIndexFilterCommand(OperationContext* txn,
BSONObj& cmdObj,
BSONObjBuilder* bob) {
// This is a read lock. The query settings is owned by the collection.
- AutoGetCollectionForRead ctx(txn, ns);
+ AutoGetCollectionForRead ctx(txn, NamespaceString(ns));
QuerySettings* querySettings;
PlanCache* planCache;
diff --git a/src/mongo/db/commands/mr.cpp b/src/mongo/db/commands/mr.cpp
index fd45c5dd115..25572a18636 100644
--- a/src/mongo/db/commands/mr.cpp
+++ b/src/mongo/db/commands/mr.cpp
@@ -53,7 +53,6 @@
#include "mongo/db/index/index_descriptor.h"
#include "mongo/db/matcher/extensions_callback_real.h"
#include "mongo/db/matcher/matcher.h"
-#include "mongo/db/namespace_string.h"
#include "mongo/db/op_observer.h"
#include "mongo/db/ops/insert.h"
#include "mongo/db/query/find_common.h"
@@ -281,11 +280,10 @@ Config::Config(const string& _dbname, const BSONObj& cmdObj) {
uassert(ErrorCodes::TypeMismatch,
str::stream() << "'mapReduce' must be of type String",
cmdObj.firstElement().type() == BSONType::String);
- const NamespaceString nss(dbname, cmdObj.firstElement().valueStringData());
+ nss = NamespaceString(dbname, cmdObj.firstElement().valueStringData());
uassert(ErrorCodes::InvalidNamespace,
str::stream() << "Invalid namespace: " << nss.ns(),
nss.isValid());
- ns = nss.ns();
verbose = cmdObj["verbose"].trueValue();
jsMode = cmdObj["jsMode"].trueValue();
@@ -312,13 +310,11 @@ Config::Config(const string& _dbname, const BSONObj& cmdObj) {
}
if (outputOptions.outType != INMEMORY) { // setup temp collection name
- tempNamespace =
- NamespaceString(outputOptions.outDB.empty() ? dbname : outputOptions.outDB,
- str::stream() << "tmp.mr." << cmdObj.firstElement().valueStringData()
- << "_"
- << JOB_NUMBER.fetchAndAdd(1))
- .ns();
- incLong = tempNamespace + "_inc";
+ tempNamespace = NamespaceString(
+ outputOptions.outDB.empty() ? dbname : outputOptions.outDB,
+ str::stream() << "tmp.mr." << cmdObj.firstElement().valueStringData() << "_"
+ << JOB_NUMBER.fetchAndAdd(1));
+ incLong = NamespaceString(str::stream() << tempNamespace.ns() << "_inc");
}
{
@@ -373,25 +369,26 @@ Config::Config(const string& _dbname, const BSONObj& cmdObj) {
* Clean up the temporary and incremental collections
*/
void State::dropTempCollections() {
- if (!_config.tempNamespace.empty()) {
+ if (!_config.tempNamespace.isEmpty()) {
MONGO_WRITE_CONFLICT_RETRY_LOOP_BEGIN {
ScopedTransaction scopedXact(_txn, MODE_IX);
- AutoGetDb autoDb(_txn, nsToDatabaseSubstring(_config.tempNamespace), MODE_X);
+ AutoGetDb autoDb(_txn, _config.tempNamespace.db(), MODE_X);
if (auto db = autoDb.getDb()) {
WriteUnitOfWork wunit(_txn);
- NamespaceString tempNss(_config.tempNamespace);
uassert(ErrorCodes::PrimarySteppedDown,
"no longer primary",
- repl::getGlobalReplicationCoordinator()->canAcceptWritesFor(tempNss));
- db->dropCollection(_txn, _config.tempNamespace);
+ repl::getGlobalReplicationCoordinator()->canAcceptWritesFor(
+ _config.tempNamespace));
+ db->dropCollection(_txn, _config.tempNamespace.ns());
wunit.commit();
}
}
- MONGO_WRITE_CONFLICT_RETRY_LOOP_END(_txn, "M/R dropTempCollections", _config.tempNamespace)
+ MONGO_WRITE_CONFLICT_RETRY_LOOP_END(
+ _txn, "M/R dropTempCollections", _config.tempNamespace.ns())
// Always forget about temporary namespaces, so we don't cache lots of them
- ShardConnection::forgetNS(_config.tempNamespace);
+ ShardConnection::forgetNS(_config.tempNamespace.ns());
}
- if (_useIncremental && !_config.incLong.empty()) {
+ if (_useIncremental && !_config.incLong.isEmpty()) {
// We don't want to log the deletion of incLong as it isn't replicated. While
// harmless, this would lead to a scary looking warning on the secondaries.
bool shouldReplicateWrites = _txn->writesAreReplicated();
@@ -400,16 +397,16 @@ void State::dropTempCollections() {
MONGO_WRITE_CONFLICT_RETRY_LOOP_BEGIN {
ScopedTransaction scopedXact(_txn, MODE_IX);
- Lock::DBLock lk(_txn->lockState(), nsToDatabaseSubstring(_config.incLong), MODE_X);
- if (Database* db = dbHolder().get(_txn, _config.incLong)) {
+ Lock::DBLock lk(_txn->lockState(), _config.incLong.db(), MODE_X);
+ if (Database* db = dbHolder().get(_txn, _config.incLong.ns())) {
WriteUnitOfWork wunit(_txn);
- db->dropCollection(_txn, _config.incLong);
+ db->dropCollection(_txn, _config.incLong.ns());
wunit.commit();
}
}
- MONGO_WRITE_CONFLICT_RETRY_LOOP_END(_txn, "M/R dropTempCollections", _config.incLong)
+ MONGO_WRITE_CONFLICT_RETRY_LOOP_END(_txn, "M/R dropTempCollections", _config.incLong.ns())
- ShardConnection::forgetNS(_config.incLong);
+ ShardConnection::forgetNS(_config.incLong.ns());
}
}
@@ -429,7 +426,7 @@ void State::prepTempCollection() {
ON_BLOCK_EXIT(&OperationContext::setReplicatedWrites, _txn, shouldReplicateWrites);
MONGO_WRITE_CONFLICT_RETRY_LOOP_BEGIN {
- OldClientWriteContext incCtx(_txn, _config.incLong);
+ OldClientWriteContext incCtx(_txn, _config.incLong.ns());
WriteUnitOfWork wuow(_txn);
Collection* incColl = incCtx.getCollection();
invariant(!incColl);
@@ -437,30 +434,31 @@ void State::prepTempCollection() {
CollectionOptions options;
options.setNoIdIndex();
options.temp = true;
- incColl = incCtx.db()->createCollection(_txn, _config.incLong, options);
+ incColl = incCtx.db()->createCollection(_txn, _config.incLong.ns(), options);
invariant(incColl);
// We explicitly create a v=2 index on the "0" field so that it is always possible for a
// user to emit() decimal keys. Since the incremental collection is not replicated to
// any secondaries, there is no risk of inadvertently crashing an older version of
// MongoDB when the featureCompatibilityVersion of this server is 3.2.
- BSONObj indexSpec = BSON("key" << BSON("0" << 1) << "ns" << _config.incLong << "name"
- << "_temp_0"
- << "v"
- << static_cast<int>(IndexVersion::kV2));
+ BSONObj indexSpec =
+ BSON("key" << BSON("0" << 1) << "ns" << _config.incLong.ns() << "name"
+ << "_temp_0"
+ << "v"
+ << static_cast<int>(IndexVersion::kV2));
Status status = incColl->getIndexCatalog()
->createIndexOnEmptyCollection(_txn, indexSpec)
.getStatus();
if (!status.isOK()) {
uasserted(17305,
str::stream() << "createIndex failed for mr incLong ns: "
- << _config.incLong
+ << _config.incLong.ns()
<< " err: "
<< status.code());
}
wuow.commit();
}
- MONGO_WRITE_CONFLICT_RETRY_LOOP_END(_txn, "M/R prepTempCollection", _config.incLong);
+ MONGO_WRITE_CONFLICT_RETRY_LOOP_END(_txn, "M/R prepTempCollection", _config.incLong.ns());
}
CollectionOptions finalOptions;
@@ -468,7 +466,7 @@ void State::prepTempCollection() {
{
// copy indexes and collection options into temporary storage
- OldClientWriteContext finalCtx(_txn, _config.outputOptions.finalNamespace);
+ OldClientWriteContext finalCtx(_txn, _config.outputOptions.finalNamespace.ns());
Collection* const finalColl = finalCtx.getCollection();
if (finalColl) {
finalOptions = finalColl->getCatalogEntry()->getCollectionOptions(_txn);
@@ -479,7 +477,7 @@ void State::prepTempCollection() {
while (ii.more()) {
IndexDescriptor* currIndex = ii.next();
BSONObjBuilder b;
- b.append("ns", _config.tempNamespace);
+ b.append("ns", _config.tempNamespace.ns());
// Copy over contents of the index descriptor's infoObj.
BSONObjIterator j(currIndex->infoObj());
@@ -496,18 +494,17 @@ void State::prepTempCollection() {
MONGO_WRITE_CONFLICT_RETRY_LOOP_BEGIN {
// create temp collection and insert the indexes from temporary storage
- OldClientWriteContext tempCtx(_txn, _config.tempNamespace);
+ OldClientWriteContext tempCtx(_txn, _config.tempNamespace.ns());
WriteUnitOfWork wuow(_txn);
- NamespaceString tempNss(_config.tempNamespace);
uassert(ErrorCodes::PrimarySteppedDown,
"no longer primary",
- repl::getGlobalReplicationCoordinator()->canAcceptWritesFor(tempNss));
+ repl::getGlobalReplicationCoordinator()->canAcceptWritesFor(_config.tempNamespace));
Collection* tempColl = tempCtx.getCollection();
invariant(!tempColl);
CollectionOptions options = finalOptions;
options.temp = true;
- tempColl = tempCtx.db()->createCollection(_txn, _config.tempNamespace, options);
+ tempColl = tempCtx.db()->createCollection(_txn, _config.tempNamespace.ns(), options);
for (vector<BSONObj>::iterator it = indexesToInsert.begin(); it != indexesToInsert.end();
++it) {
@@ -520,12 +517,12 @@ void State::prepTempCollection() {
uassertStatusOK(status);
}
// Log the createIndex operation.
- string logNs = nsToDatabase(_config.tempNamespace) + ".system.indexes";
+ string logNs = _config.tempNamespace.db() + ".system.indexes";
getGlobalServiceContext()->getOpObserver()->onCreateIndex(_txn, logNs, *it, false);
}
wuow.commit();
}
- MONGO_WRITE_CONFLICT_RETRY_LOOP_END(_txn, "M/R prepTempCollection", _config.tempNamespace)
+ MONGO_WRITE_CONFLICT_RETRY_LOOP_END(_txn, "M/R prepTempCollection", _config.tempNamespace.ns())
}
/**
@@ -551,7 +548,7 @@ void State::appendResults(BSONObjBuilder& final) {
BSONObj res;
BSONObj idKey = BSON("_id" << 1);
if (!_db.runCommand("admin",
- BSON("splitVector" << _config.outputOptions.finalNamespace
+ BSON("splitVector" << _config.outputOptions.finalNamespace.ns()
<< "keyPattern"
<< idKey
<< "maxChunkSizeBytes"
@@ -630,7 +627,7 @@ namespace {
// Runs a count against the namespace specified by 'ns'. If the caller holds the global write lock,
// then this function does not acquire any additional locks.
unsigned long long _collectionCount(OperationContext* txn,
- const string& ns,
+ const NamespaceString& nss,
bool callerHoldsGlobalLock) {
Collection* coll = nullptr;
boost::optional<AutoGetCollectionForRead> ctx;
@@ -638,12 +635,12 @@ unsigned long long _collectionCount(OperationContext* txn,
// If the global write lock is held, we must avoid using AutoGetCollectionForRead as it may lead
// to deadlock when waiting for a majority snapshot to be committed. See SERVER-24596.
if (callerHoldsGlobalLock) {
- Database* db = dbHolder().get(txn, ns);
+ Database* db = dbHolder().get(txn, nss.ns());
if (db) {
- coll = db->getCollection(ns);
+ coll = db->getCollection(nss);
}
} else {
- ctx.emplace(txn, NamespaceString(ns));
+ ctx.emplace(txn, nss);
coll = ctx->getCollection();
}
@@ -665,19 +662,19 @@ long long State::postProcessCollectionNonAtomic(OperationContext* txn,
// This must be global because we may write across different databases.
Lock::GlobalWrite lock(txn->lockState());
// replace: just rename from temp to final collection name, dropping previous collection
- _db.dropCollection(_config.outputOptions.finalNamespace);
+ _db.dropCollection(_config.outputOptions.finalNamespace.ns());
BSONObj info;
if (!_db.runCommand("admin",
- BSON("renameCollection" << _config.tempNamespace << "to"
- << _config.outputOptions.finalNamespace
+ BSON("renameCollection" << _config.tempNamespace.ns() << "to"
+ << _config.outputOptions.finalNamespace.ns()
<< "stayTemp"
<< _config.shardedFirstPass),
info)) {
uasserted(10076, str::stream() << "rename failed: " << info);
}
- _db.dropCollection(_config.tempNamespace);
+ _db.dropCollection(_config.tempNamespace.ns());
} else if (_config.outputOptions.outType == Config::MERGE) {
// merge: upsert new docs into old collection
{
@@ -686,17 +683,15 @@ long long State::postProcessCollectionNonAtomic(OperationContext* txn,
curOp->setMessage_inlock(
"m/r: merge post processing", "M/R Merge Post Processing Progress", count);
}
- unique_ptr<DBClientCursor> cursor = _db.query(_config.tempNamespace, BSONObj());
+ unique_ptr<DBClientCursor> cursor = _db.query(_config.tempNamespace.ns(), BSONObj());
while (cursor->more()) {
ScopedTransaction scopedXact(txn, MODE_X);
- Lock::DBLock lock(txn->lockState(),
- nsToDatabaseSubstring(_config.outputOptions.finalNamespace),
- MODE_X);
+ Lock::DBLock lock(txn->lockState(), _config.outputOptions.finalNamespace.db(), MODE_X);
BSONObj o = cursor->nextSafe();
- Helpers::upsert(txn, _config.outputOptions.finalNamespace, o);
+ Helpers::upsert(txn, _config.outputOptions.finalNamespace.ns(), o);
pm.hit();
}
- _db.dropCollection(_config.tempNamespace);
+ _db.dropCollection(_config.tempNamespace.ns());
pm.finished();
} else if (_config.outputOptions.outType == Config::REDUCE) {
// reduce: apply reduce op on new result and existing one
@@ -708,7 +703,7 @@ long long State::postProcessCollectionNonAtomic(OperationContext* txn,
curOp->setMessage_inlock(
"m/r: reduce post processing", "M/R Reduce Post Processing Progress", count);
}
- unique_ptr<DBClientCursor> cursor = _db.query(_config.tempNamespace, BSONObj());
+ unique_ptr<DBClientCursor> cursor = _db.query(_config.tempNamespace.ns(), BSONObj());
while (cursor->more()) {
ScopedTransaction transaction(txn, MODE_X);
// This must be global because we may write across different databases.
@@ -718,9 +713,9 @@ long long State::postProcessCollectionNonAtomic(OperationContext* txn,
bool found;
{
- const std::string& finalNamespace = _config.outputOptions.finalNamespace;
- OldClientContext tx(txn, finalNamespace);
- Collection* coll = getCollectionOrUassert(tx.db(), finalNamespace);
+ OldClientContext tx(txn, _config.outputOptions.finalNamespace.ns());
+ Collection* coll =
+ getCollectionOrUassert(tx.db(), _config.outputOptions.finalNamespace);
found = Helpers::findOne(txn, coll, temp["_id"].wrap(), old, true);
}
@@ -730,10 +725,10 @@ long long State::postProcessCollectionNonAtomic(OperationContext* txn,
values.push_back(temp);
values.push_back(old);
Helpers::upsert(txn,
- _config.outputOptions.finalNamespace,
+ _config.outputOptions.finalNamespace.ns(),
_config.reducer->finalReduce(values, _config.finalizer.get()));
} else {
- Helpers::upsert(txn, _config.outputOptions.finalNamespace, temp);
+ Helpers::upsert(txn, _config.outputOptions.finalNamespace.ns(), temp);
}
pm.hit();
}
@@ -746,17 +741,16 @@ long long State::postProcessCollectionNonAtomic(OperationContext* txn,
/**
* Insert doc in collection. This should be replicated.
*/
-void State::insert(const string& ns, const BSONObj& o) {
+void State::insert(const NamespaceString& nss, const BSONObj& o) {
verify(_onDisk);
MONGO_WRITE_CONFLICT_RETRY_LOOP_BEGIN {
- OldClientWriteContext ctx(_txn, ns);
+ OldClientWriteContext ctx(_txn, nss.ns());
WriteUnitOfWork wuow(_txn);
- NamespaceString nss(ns);
uassert(ErrorCodes::PrimarySteppedDown,
"no longer primary",
repl::getGlobalReplicationCoordinator()->canAcceptWritesFor(nss));
- Collection* coll = getCollectionOrUassert(ctx.db(), ns);
+ Collection* coll = getCollectionOrUassert(ctx.db(), nss);
BSONObjBuilder b;
if (!o.hasField("_id")) {
@@ -776,7 +770,7 @@ void State::insert(const string& ns, const BSONObj& o) {
uassertStatusOK(coll->insertDocument(_txn, bo, nullOpDebug, true));
wuow.commit();
}
- MONGO_WRITE_CONFLICT_RETRY_LOOP_END(_txn, "M/R insert", ns);
+ MONGO_WRITE_CONFLICT_RETRY_LOOP_END(_txn, "M/R insert", nss.ns());
}
/**
@@ -786,7 +780,7 @@ void State::_insertToInc(BSONObj& o) {
verify(_onDisk);
MONGO_WRITE_CONFLICT_RETRY_LOOP_BEGIN {
- OldClientWriteContext ctx(_txn, _config.incLong);
+ OldClientWriteContext ctx(_txn, _config.incLong.ns());
WriteUnitOfWork wuow(_txn);
Collection* coll = getCollectionOrUassert(ctx.db(), _config.incLong);
bool shouldReplicateWrites = _txn->writesAreReplicated();
@@ -811,7 +805,7 @@ void State::_insertToInc(BSONObj& o) {
uassertStatusOK(coll->insertDocument(_txn, o, nullOpDebug, true, false));
wuow.commit();
}
- MONGO_WRITE_CONFLICT_RETRY_LOOP_END(_txn, "M/R insertToInc", _config.incLong);
+ MONGO_WRITE_CONFLICT_RETRY_LOOP_END(_txn, "M/R insertToInc", _config.incLong.ns());
}
State::State(OperationContext* txn, const Config& c)
@@ -821,7 +815,7 @@ State::State(OperationContext* txn, const Config& c)
}
bool State::sourceExists() {
- return _db.exists(_config.ns);
+ return _db.exists(_config.nss.ns());
}
State::~State() {
@@ -993,9 +987,9 @@ void State::bailFromJS() {
_config.reducer->numReduces = _scope->getNumberInt("_redCt");
}
-Collection* State::getCollectionOrUassert(Database* db, StringData ns) {
- Collection* out = db ? db->getCollection(ns) : NULL;
- uassert(18697, "Collection unexpectedly disappeared: " + ns.toString(), out);
+Collection* State::getCollectionOrUassert(Database* db, const NamespaceString& nss) {
+ Collection* out = db ? db->getCollection(nss) : NULL;
+ uassert(18697, "Collection unexpectedly disappeared: " + nss.ns(), out);
return out;
}
@@ -1070,7 +1064,7 @@ void State::finalReduce(OperationContext* txn, CurOp* curOp, ProgressMeterHolder
BSONObj sortKey = BSON("0" << 1);
MONGO_WRITE_CONFLICT_RETRY_LOOP_BEGIN {
- OldClientWriteContext incCtx(_txn, _config.incLong);
+ OldClientWriteContext incCtx(_txn, _config.incLong.ns());
WriteUnitOfWork wuow(_txn);
Collection* incColl = getCollectionOrUassert(incCtx.db(), _config.incLong);
@@ -1089,7 +1083,7 @@ void State::finalReduce(OperationContext* txn, CurOp* curOp, ProgressMeterHolder
verify(foundIndex);
wuow.commit();
}
- MONGO_WRITE_CONFLICT_RETRY_LOOP_END(_txn, "finalReduce", _config.incLong);
+ MONGO_WRITE_CONFLICT_RETRY_LOOP_END(_txn, "finalReduce", _config.incLong.ns());
unique_ptr<AutoGetCollectionForRead> ctx(new AutoGetCollectionForRead(_txn, _config.incLong));
@@ -1097,7 +1091,7 @@ void State::finalReduce(OperationContext* txn, CurOp* curOp, ProgressMeterHolder
BSONList all;
{
- const auto count = _db.count(_config.incLong, BSONObj(), QueryOption_SlaveOk);
+ const auto count = _db.count(_config.incLong.ns(), BSONObj(), QueryOption_SlaveOk);
stdx::lock_guard<Client> lk(*_txn->getClient());
verify(pm ==
curOp->setMessage_inlock("m/r: (3/3) final reduce to collection",
@@ -1105,10 +1099,9 @@ void State::finalReduce(OperationContext* txn, CurOp* curOp, ProgressMeterHolder
count));
}
- const NamespaceString nss(_config.incLong);
- const ExtensionsCallbackReal extensionsCallback(_txn, &nss);
+ const ExtensionsCallbackReal extensionsCallback(_txn, &_config.incLong);
- auto qr = stdx::make_unique<QueryRequest>(nss);
+ auto qr = stdx::make_unique<QueryRequest>(_config.incLong);
qr->setSort(sortKey);
auto statusWithCQ = CanonicalQuery::canonicalize(txn, std::move(qr), extensionsCallback);
@@ -1389,7 +1382,7 @@ public:
auto curOp = CurOp::get(txn);
- Config config(dbname, cmd);
+ const Config config(dbname, cmd);
if (!config.collation.isEmpty() &&
serverGlobalParams.featureCompatibility.version.load() ==
@@ -1401,7 +1394,7 @@ public:
"http://dochub.mongodb.org/core/3.4-feature-compatibility."));
}
- LOG(1) << "mr ns: " << config.ns;
+ LOG(1) << "mr ns: " << config.nss;
uassert(16149, "cannot run map reduce without the js engine", getGlobalScriptEngine());
@@ -1409,7 +1402,7 @@ public:
unique_ptr<RangePreserver> rangePreserver;
ScopedCollectionMetadata collMetadata;
{
- AutoGetCollectionForRead ctx(txn, config.ns);
+ AutoGetCollectionForRead ctx(txn, config.nss);
Collection* collection = ctx.getCollection();
if (collection) {
@@ -1418,8 +1411,8 @@ public:
// Get metadata before we check our version, to make sure it doesn't increment
// in the meantime. Need to do this in the same lock scope as the block.
- if (ShardingState::get(txn)->needCollectionMetadata(txn, config.ns)) {
- collMetadata = CollectionShardingState::get(txn, config.ns)->getMetadata();
+ if (ShardingState::get(txn)->needCollectionMetadata(txn, config.nss.ns())) {
+ collMetadata = CollectionShardingState::get(txn, config.nss)->getMetadata();
}
}
@@ -1428,7 +1421,7 @@ public:
// be done under the lock.
ON_BLOCK_EXIT([txn, &config, &rangePreserver] {
if (rangePreserver) {
- AutoGetCollectionForRead ctx(txn, config.ns);
+ AutoGetCollectionForRead ctx(txn, config.nss);
rangePreserver.reset();
}
});
@@ -1445,8 +1438,7 @@ public:
if (state.isOnDisk()) {
// this means that it will be doing a write operation, make sure we are on Master
// ideally this check should be in slaveOk(), but at that point config is not known
- NamespaceString nss(config.ns);
- if (!repl::getGlobalReplicationCoordinator()->canAcceptWritesFor(nss)) {
+ if (!repl::getGlobalReplicationCoordinator()->canAcceptWritesFor(config.nss)) {
errmsg = "not master";
return false;
}
@@ -1461,7 +1453,7 @@ public:
bool showTotal = true;
if (state.config().filter.isEmpty()) {
const bool holdingGlobalLock = false;
- const auto count = _collectionCount(txn, config.ns, holdingGlobalLock);
+ const auto count = _collectionCount(txn, config.nss, holdingGlobalLock);
progressTotal =
(config.limit && (unsigned)config.limit < count) ? config.limit : count;
} else {
@@ -1488,18 +1480,16 @@ public:
// We've got a cursor preventing migrations off, now re-establish our
// useful cursor.
- const NamespaceString nss(config.ns);
-
// Need lock and context to use it
unique_ptr<ScopedTransaction> scopedXact(new ScopedTransaction(txn, MODE_IS));
- unique_ptr<AutoGetDb> scopedAutoDb(new AutoGetDb(txn, nss.db(), MODE_S));
+ unique_ptr<AutoGetDb> scopedAutoDb(new AutoGetDb(txn, config.nss.db(), MODE_S));
- auto qr = stdx::make_unique<QueryRequest>(nss);
+ auto qr = stdx::make_unique<QueryRequest>(config.nss);
qr->setFilter(config.filter);
qr->setSort(config.sort);
qr->setCollation(config.collation);
- const ExtensionsCallbackReal extensionsCallback(txn, &nss);
+ const ExtensionsCallbackReal extensionsCallback(txn, &config.nss);
auto statusWithCQ =
CanonicalQuery::canonicalize(txn, std::move(qr), extensionsCallback);
@@ -1512,7 +1502,7 @@ public:
unique_ptr<PlanExecutor> exec;
{
Database* db = scopedAutoDb->getDb();
- Collection* coll = State::getCollectionOrUassert(db, config.ns);
+ Collection* coll = State::getCollectionOrUassert(db, config.nss);
invariant(coll);
auto statusWithPlanExecutor =
@@ -1572,7 +1562,7 @@ public:
state.reduceAndSpillInMemoryStateIfNeeded();
scopedXact.reset(new ScopedTransaction(txn, MODE_IS));
- scopedAutoDb.reset(new AutoGetDb(txn, nss.db(), MODE_S));
+ scopedAutoDb.reset(new AutoGetDb(txn, config.nss.db(), MODE_S));
if (!exec->restoreState()) {
return appendCommandStatus(
@@ -1609,7 +1599,7 @@ public:
// metrics. There is no harm adding here for the time being.
curOp->debug().setPlanSummaryMetrics(stats);
- Collection* coll = scopedAutoDb->getDb()->getCollection(config.ns);
+ Collection* coll = scopedAutoDb->getDb()->getCollection(config.nss);
invariant(coll); // 'exec' hasn't been killed, so collection must be alive.
coll->infoCache()->notifyOfQuery(txn, stats.indexesUsed);
@@ -1807,9 +1797,9 @@ public:
shared_ptr<DBConfig> confOut = status.getValue();
vector<shared_ptr<Chunk>> chunks;
- if (confOut->isSharded(config.outputOptions.finalNamespace)) {
+ if (confOut->isSharded(config.outputOptions.finalNamespace.ns())) {
shared_ptr<ChunkManager> cm =
- confOut->getChunkManager(txn, config.outputOptions.finalNamespace);
+ confOut->getChunkManager(txn, config.outputOptions.finalNamespace.ns());
// Fetch result from other shards 1 chunk at a time. It would be better to do
// just one big $or query, but then the sorting would not be efficient.
diff --git a/src/mongo/db/commands/mr.h b/src/mongo/db/commands/mr.h
index 89738ea1259..aa729f49e7f 100644
--- a/src/mongo/db/commands/mr.h
+++ b/src/mongo/db/commands/mr.h
@@ -37,6 +37,7 @@
#include "mongo/db/curop.h"
#include "mongo/db/dbdirectclient.h"
#include "mongo/db/jsobj.h"
+#include "mongo/db/namespace_string.h"
#include "mongo/platform/atomic_word.h"
#include "mongo/scripting/engine.h"
@@ -195,7 +196,7 @@ public:
Config(const std::string& _dbname, const BSONObj& cmdObj);
std::string dbname;
- std::string ns;
+ NamespaceString nss;
// options
bool verbose;
@@ -219,8 +220,8 @@ public:
BSONObj scopeSetup;
// output tables
- std::string incLong;
- std::string tempNamespace;
+ NamespaceString incLong;
+ NamespaceString tempNamespace;
enum OutputType {
REPLACE, // atomically replace the collection
@@ -231,7 +232,7 @@ public:
struct OutputOptions {
std::string outDB;
std::string collectionName;
- std::string finalNamespace;
+ NamespaceString finalNamespace;
// if true, no lock during output operation
bool outNonAtomic;
OutputType outType;
@@ -333,7 +334,7 @@ public:
/**
* inserts with correct replication semantics
*/
- void insert(const std::string& ns, const BSONObj& o);
+ void insert(const NamespaceString& nss, const BSONObj& o);
// ------ simple accessors -----
@@ -372,7 +373,7 @@ public:
void switchMode(bool jsMode);
void bailFromJS();
- static Collection* getCollectionOrUassert(Database* db, StringData ns);
+ static Collection* getCollectionOrUassert(Database* db, const NamespaceString& nss);
const Config& _config;
DBDirectClient _db;
diff --git a/src/mongo/db/commands/mr_common.cpp b/src/mongo/db/commands/mr_common.cpp
index 1356a6f6fb2..0ca08c82aa0 100644
--- a/src/mongo/db/commands/mr_common.cpp
+++ b/src/mongo/db/commands/mr_common.cpp
@@ -93,7 +93,7 @@ Config::OutputOptions Config::parseOutputOptions(const std::string& dbname, cons
uassert(ErrorCodes::InvalidNamespace,
str::stream() << "Invalid 'out' namespace: " << nss.ns(),
nss.isValid());
- outputOptions.finalNamespace = nss.ns();
+ outputOptions.finalNamespace = std::move(nss);
}
return outputOptions;
diff --git a/src/mongo/db/commands/mr_test.cpp b/src/mongo/db/commands/mr_test.cpp
index 0d9f5f7edca..406feab7487 100644
--- a/src/mongo/db/commands/mr_test.cpp
+++ b/src/mongo/db/commands/mr_test.cpp
@@ -96,8 +96,11 @@ void _testConfigParseOutputOptions(const std::string& dbname,
_compareOutputOptionField(dbname, cmdObjStr, "outDb", outputOptions.outDB, expectedOutDb);
_compareOutputOptionField(
dbname, cmdObjStr, "collectionName", outputOptions.collectionName, expectedCollectionName);
- _compareOutputOptionField(
- dbname, cmdObjStr, "finalNamespace", outputOptions.finalNamespace, expectedFinalNamespace);
+ _compareOutputOptionField(dbname,
+ cmdObjStr,
+ "finalNamespace",
+ outputOptions.finalNamespace.ns(),
+ expectedFinalNamespace);
_compareOutputOptionField(
dbname, cmdObjStr, "outNonAtomic", outputOptions.outNonAtomic, expectedOutNonAtomic);
_compareOutputOptionField(dbname,
diff --git a/src/mongo/db/commands/parallel_collection_scan.cpp b/src/mongo/db/commands/parallel_collection_scan.cpp
index 75b0e59512b..41689016961 100644
--- a/src/mongo/db/commands/parallel_collection_scan.cpp
+++ b/src/mongo/db/commands/parallel_collection_scan.cpp
@@ -36,6 +36,7 @@
#include "mongo/db/curop.h"
#include "mongo/db/db_raii.h"
#include "mongo/db/exec/multi_iterator.h"
+#include "mongo/db/namespace_string.h"
#include "mongo/db/query/cursor_response.h"
#include "mongo/db/service_context.h"
#include "mongo/stdx/memory.h"
@@ -92,7 +93,7 @@ public:
BSONObjBuilder& result) {
const NamespaceString ns(parseNsCollectionRequired(dbname, cmdObj));
- AutoGetCollectionForRead ctx(txn, ns.ns());
+ AutoGetCollectionForRead ctx(txn, ns);
Collection* collection = ctx.getCollection();
if (!collection)
diff --git a/src/mongo/db/commands/plan_cache_commands.cpp b/src/mongo/db/commands/plan_cache_commands.cpp
index fe713a0667f..67b244d6bb3 100644
--- a/src/mongo/db/commands/plan_cache_commands.cpp
+++ b/src/mongo/db/commands/plan_cache_commands.cpp
@@ -43,6 +43,7 @@
#include "mongo/db/db_raii.h"
#include "mongo/db/jsobj.h"
#include "mongo/db/matcher/extensions_callback_real.h"
+#include "mongo/db/namespace_string.h"
#include "mongo/db/query/explain.h"
#include "mongo/db/query/plan_ranker.h"
#include "mongo/util/log.h"
@@ -226,7 +227,7 @@ Status PlanCacheListQueryShapes::runPlanCacheCommand(OperationContext* txn,
BSONObj& cmdObj,
BSONObjBuilder* bob) {
// This is a read lock. The query cache is owned by the collection.
- AutoGetCollectionForRead ctx(txn, ns);
+ AutoGetCollectionForRead ctx(txn, NamespaceString(ns));
PlanCache* planCache;
Status status = getPlanCache(txn, ctx.getCollection(), ns, &planCache);
@@ -278,7 +279,7 @@ Status PlanCacheClear::runPlanCacheCommand(OperationContext* txn,
BSONObj& cmdObj,
BSONObjBuilder* bob) {
// This is a read lock. The query cache is owned by the collection.
- AutoGetCollectionForRead ctx(txn, ns);
+ AutoGetCollectionForRead ctx(txn, NamespaceString(ns));
PlanCache* planCache;
Status status = getPlanCache(txn, ctx.getCollection(), ns, &planCache);
@@ -354,7 +355,7 @@ Status PlanCacheListPlans::runPlanCacheCommand(OperationContext* txn,
const std::string& ns,
BSONObj& cmdObj,
BSONObjBuilder* bob) {
- AutoGetCollectionForRead ctx(txn, ns);
+ AutoGetCollectionForRead ctx(txn, NamespaceString(ns));
PlanCache* planCache;
Status status = getPlanCache(txn, ctx.getCollection(), ns, &planCache);
diff --git a/src/mongo/db/commands/repair_cursor.cpp b/src/mongo/db/commands/repair_cursor.cpp
index 1db01e81dd2..4e34e0bbb0f 100644
--- a/src/mongo/db/commands/repair_cursor.cpp
+++ b/src/mongo/db/commands/repair_cursor.cpp
@@ -38,6 +38,7 @@
#include "mongo/db/commands.h"
#include "mongo/db/db_raii.h"
#include "mongo/db/exec/multi_iterator.h"
+#include "mongo/db/namespace_string.h"
#include "mongo/db/query/cursor_response.h"
namespace mongo {
@@ -74,7 +75,7 @@ public:
BSONObjBuilder& result) {
NamespaceString ns(parseNs(dbname, cmdObj));
- AutoGetCollectionForRead ctx(txn, ns.ns());
+ AutoGetCollectionForRead ctx(txn, ns);
Collection* collection = ctx.getCollection();
if (!collection) {
diff --git a/src/mongo/db/db_raii.h b/src/mongo/db/db_raii.h
index 97b48a32c65..dc2cf8c0aaa 100644
--- a/src/mongo/db/db_raii.h
+++ b/src/mongo/db/db_raii.h
@@ -166,10 +166,6 @@ class AutoGetCollectionForRead {
MONGO_DISALLOW_COPYING(AutoGetCollectionForRead);
public:
- AutoGetCollectionForRead(OperationContext* txn, const std::string& ns)
- : AutoGetCollectionForRead(
- txn, NamespaceString(ns), AutoGetCollection::ViewMode::kViewsForbidden) {}
-
AutoGetCollectionForRead(OperationContext* txn, const NamespaceString& nss)
: AutoGetCollectionForRead(txn, nss, AutoGetCollection::ViewMode::kViewsForbidden) {}
@@ -211,9 +207,6 @@ class AutoGetCollectionOrViewForRead final : public AutoGetCollectionForRead {
MONGO_DISALLOW_COPYING(AutoGetCollectionOrViewForRead);
public:
- AutoGetCollectionOrViewForRead(OperationContext* txn, const std::string& ns)
- : AutoGetCollectionOrViewForRead(txn, NamespaceString(ns)) {}
-
AutoGetCollectionOrViewForRead(OperationContext* txn, const NamespaceString& nss);
ViewDefinition* getView() const {
diff --git a/src/mongo/db/dbhelpers.cpp b/src/mongo/db/dbhelpers.cpp
index daf2767c908..a030d2b579f 100644
--- a/src/mongo/db/dbhelpers.cpp
+++ b/src/mongo/db/dbhelpers.cpp
@@ -44,6 +44,7 @@
#include "mongo/db/json.h"
#include "mongo/db/keypattern.h"
#include "mongo/db/matcher/extensions_callback_real.h"
+#include "mongo/db/namespace_string.h"
#include "mongo/db/op_observer.h"
#include "mongo/db/ops/delete.h"
#include "mongo/db/ops/update.h"
@@ -206,7 +207,7 @@ RecordId Helpers::findById(OperationContext* txn, Collection* collection, const
}
bool Helpers::getSingleton(OperationContext* txn, const char* ns, BSONObj& result) {
- AutoGetCollectionForRead ctx(txn, ns);
+ AutoGetCollectionForRead ctx(txn, NamespaceString(ns));
unique_ptr<PlanExecutor> exec(
InternalPlanner::collectionScan(txn, ns, ctx.getCollection(), PlanExecutor::YIELD_MANUAL));
PlanExecutor::ExecState state = exec->getNext(&result, NULL);
@@ -225,7 +226,7 @@ bool Helpers::getSingleton(OperationContext* txn, const char* ns, BSONObj& resul
}
bool Helpers::getLast(OperationContext* txn, const char* ns, BSONObj& result) {
- AutoGetCollectionForRead autoColl(txn, ns);
+ AutoGetCollectionForRead autoColl(txn, NamespaceString(ns));
unique_ptr<PlanExecutor> exec(InternalPlanner::collectionScan(
txn, ns, autoColl.getCollection(), PlanExecutor::YIELD_MANUAL, InternalPlanner::BACKWARD));
PlanExecutor::ExecState state = exec->getNext(&result, NULL);
@@ -301,7 +302,7 @@ long long Helpers::removeRange(OperationContext* txn,
bool fromMigrate,
bool onlyRemoveOrphanedDocs) {
Timer rangeRemoveTimer;
- const string& ns = range.ns;
+ const NamespaceString nss(range.ns);
// The IndexChunk has a keyPattern that may apply to more than one index - we need to
// select the index and get the full index keyPattern here.
@@ -310,12 +311,12 @@ long long Helpers::removeRange(OperationContext* txn,
BSONObj max;
{
- AutoGetCollectionForRead ctx(txn, ns);
+ AutoGetCollectionForRead ctx(txn, nss);
Collection* collection = ctx.getCollection();
if (!collection) {
warning(LogComponent::kSharding)
<< "collection deleted before cleaning data over range of type " << range.keyPattern
- << " in " << ns << endl;
+ << " in " << nss.ns() << endl;
return -1;
}
@@ -328,7 +329,7 @@ long long Helpers::removeRange(OperationContext* txn,
false); // requireSingleKey
if (!idx) {
warning(LogComponent::kSharding) << "no index found to clean data over range of type "
- << range.keyPattern << " in " << ns << endl;
+ << range.keyPattern << " in " << nss.ns() << endl;
return -1;
}
@@ -348,7 +349,7 @@ long long Helpers::removeRange(OperationContext* txn,
MONGO_LOG_COMPONENT(1, LogComponent::kSharding)
- << "begin removal of " << min << " to " << max << " in " << ns
+ << "begin removal of " << min << " to " << max << " in " << nss.ns()
<< " with write concern: " << writeConcern.toBSON() << endl;
long long numDeleted = 0;
@@ -358,7 +359,7 @@ long long Helpers::removeRange(OperationContext* txn,
while (1) {
// Scoping for write lock.
{
- AutoGetCollection ctx(txn, NamespaceString(ns), MODE_IX, MODE_IX);
+ AutoGetCollection ctx(txn, nss, MODE_IX, MODE_IX);
Collection* collection = ctx.getCollection();
if (!collection)
break;
@@ -367,7 +368,7 @@ long long Helpers::removeRange(OperationContext* txn,
if (!desc) {
warning(LogComponent::kSharding) << "shard key index '" << indexName << "' on '"
- << ns << "' was dropped";
+ << nss.ns() << "' was dropped";
return -1;
}
@@ -395,7 +396,7 @@ long long Helpers::removeRange(OperationContext* txn,
if (PlanExecutor::FAILURE == state || PlanExecutor::DEAD == state) {
warning(LogComponent::kSharding)
<< PlanExecutor::statestr(state) << " - cursor error while trying to delete "
- << min << " to " << max << " in " << ns << ": "
+ << min << " to " << max << " in " << nss.ns() << ": "
<< WorkingSetCommon::toStatusString(obj)
<< ", stats: " << Explain::getWinningPlanStats(exec.get()) << endl;
break;
@@ -417,7 +418,7 @@ long long Helpers::removeRange(OperationContext* txn,
bool docIsOrphan;
// In write lock, so will be the most up-to-date version
- auto metadataNow = CollectionShardingState::get(txn, ns)->getMetadata();
+ auto metadataNow = CollectionShardingState::get(txn, nss.ns())->getMetadata();
if (metadataNow) {
ShardKeyPattern kp(metadataNow->getKeyPattern());
BSONObj key = kp.extractShardKeyFromDoc(obj);
@@ -431,16 +432,15 @@ long long Helpers::removeRange(OperationContext* txn,
warning(LogComponent::kSharding)
<< "aborting migration cleanup for chunk " << min << " to " << max
<< (metadataNow ? (string) " at document " + obj.toString() : "")
- << ", collection " << ns << " has changed " << endl;
+ << ", collection " << nss.ns() << " has changed " << endl;
break;
}
}
- NamespaceString nss(ns);
if (!repl::getGlobalReplicationCoordinator()->canAcceptWritesFor(nss)) {
warning() << "stepped down from primary while deleting chunk; "
- << "orphaning data in " << ns << " in range [" << redact(min) << ", "
- << redact(max) << ")";
+ << "orphaning data in " << nss.ns() << " in range [" << redact(min)
+ << ", " << redact(max) << ")";
return numDeleted;
}
@@ -478,7 +478,7 @@ long long Helpers::removeRange(OperationContext* txn,
<< durationCount<Milliseconds>(millisWaitingForReplication) << "ms" << endl;
MONGO_LOG_COMPONENT(1, LogComponent::kSharding) << "end removal of " << min << " to " << max
- << " in " << ns << " (took "
+ << " in " << nss.ns() << " (took "
<< rangeRemoveTimer.millis() << "ms)" << endl;
return numDeleted;
diff --git a/src/mongo/db/namespace_string.h b/src/mongo/db/namespace_string.h
index 220c188203c..c623dbbac90 100644
--- a/src/mongo/db/namespace_string.h
+++ b/src/mongo/db/namespace_string.h
@@ -146,6 +146,10 @@ public:
return _ns.size();
}
+ bool isEmpty() const {
+ return _ns.empty();
+ }
+
struct Hasher {
size_t operator()(const NamespaceString& nss) const {
return std::hash<std::string>()(nss._ns);
diff --git a/src/mongo/db/pipeline/pipeline_d.cpp b/src/mongo/db/pipeline/pipeline_d.cpp
index 57ede6d6955..0ed23840b51 100644
--- a/src/mongo/db/pipeline/pipeline_d.cpp
+++ b/src/mongo/db/pipeline/pipeline_d.cpp
@@ -48,6 +48,7 @@
#include "mongo/db/exec/working_set.h"
#include "mongo/db/index/index_access_method.h"
#include "mongo/db/matcher/extensions_callback_real.h"
+#include "mongo/db/namespace_string.h"
#include "mongo/db/pipeline/document_source.h"
#include "mongo/db/pipeline/document_source_cursor.h"
#include "mongo/db/pipeline/document_source_match.h"
@@ -95,7 +96,7 @@ public:
}
bool isSharded(const NamespaceString& nss) final {
- AutoGetCollectionForRead autoColl(_ctx->opCtx, nss.ns());
+ AutoGetCollectionForRead autoColl(_ctx->opCtx, nss);
auto css = CollectionShardingState::get(_ctx->opCtx, nss);
return bool(css->getMetadata());
}
diff --git a/src/mongo/db/repl/master_slave.cpp b/src/mongo/db/repl/master_slave.cpp
index e625911dee5..5a05b023088 100644
--- a/src/mongo/db/repl/master_slave.cpp
+++ b/src/mongo/db/repl/master_slave.cpp
@@ -57,6 +57,7 @@
#include "mongo/db/db_raii.h"
#include "mongo/db/dbdirectclient.h"
#include "mongo/db/dbhelpers.h"
+#include "mongo/db/namespace_string.h"
#include "mongo/db/op_observer.h"
#include "mongo/db/ops/update.h"
#include "mongo/db/query/internal_plans.h"
@@ -1455,7 +1456,7 @@ void pretouchOperation(OperationContext* txn, const BSONObj& op) {
BSONObjBuilder b;
b.append(_id);
BSONObj result;
- AutoGetCollectionForRead ctx(txn, ns);
+ AutoGetCollectionForRead ctx(txn, NamespaceString(ns));
if (Helpers::findById(txn, ctx.getDb(), ns, b.done(), result)) {
_dummy_z += result.objsize(); // touch
}
diff --git a/src/mongo/db/repl/oplog.cpp b/src/mongo/db/repl/oplog.cpp
index 8c58b6d383e..3e75d04e94f 100644
--- a/src/mongo/db/repl/oplog.cpp
+++ b/src/mongo/db/repl/oplog.cpp
@@ -1244,7 +1244,7 @@ void SnapshotThread::run() {
auto opTimeOfSnapshot = OpTime();
{
- AutoGetCollectionForRead oplog(txn.get(), rsOplogName);
+ AutoGetCollectionForRead oplog(txn.get(), NamespaceString(rsOplogName));
invariant(oplog.getCollection());
// Read the latest op from the oplog.
auto cursor = oplog.getCollection()->getCursor(txn.get(), /*forward*/ false);
diff --git a/src/mongo/db/repl/replication_info.cpp b/src/mongo/db/repl/replication_info.cpp
index 0e38911533b..c75c7b38880 100644
--- a/src/mongo/db/repl/replication_info.cpp
+++ b/src/mongo/db/repl/replication_info.cpp
@@ -40,6 +40,7 @@
#include "mongo/db/exec/working_set_common.h"
#include "mongo/db/jsobj.h"
#include "mongo/db/lasterror.h"
+#include "mongo/db/namespace_string.h"
#include "mongo/db/query/internal_plans.h"
#include "mongo/db/repl/is_master_response.h"
#include "mongo/db/repl/master_slave.h"
@@ -93,10 +94,10 @@ void appendReplicationInfo(OperationContext* txn, BSONObjBuilder& result, int le
int n = 0;
list<BSONObj> src;
{
- const char* localSources = "local.sources";
+ const NamespaceString localSources{"local.sources"};
AutoGetCollectionForRead ctx(txn, localSources);
unique_ptr<PlanExecutor> exec(InternalPlanner::collectionScan(
- txn, localSources, ctx.getCollection(), PlanExecutor::YIELD_MANUAL));
+ txn, localSources.ns(), ctx.getCollection(), PlanExecutor::YIELD_MANUAL));
BSONObj obj;
PlanExecutor::ExecState state;
while (PlanExecutor::ADVANCED == (state = exec->getNext(&obj, NULL))) {
diff --git a/src/mongo/db/repl/rs_rollback_test.cpp b/src/mongo/db/repl/rs_rollback_test.cpp
index 14f42cb7158..edcf8668c16 100644
--- a/src/mongo/db/repl/rs_rollback_test.cpp
+++ b/src/mongo/db/repl/rs_rollback_test.cpp
@@ -44,6 +44,7 @@
#include "mongo/db/dbhelpers.h"
#include "mongo/db/index/index_descriptor.h"
#include "mongo/db/jsobj.h"
+#include "mongo/db/namespace_string.h"
#include "mongo/db/repl/oplog.h"
#include "mongo/db/repl/oplog_interface.h"
#include "mongo/db/repl/oplog_interface_mock.h"
@@ -875,7 +876,7 @@ TEST_F(RSRollbackTest, RollbackApplyOpsCommand) {
ASSERT_EQUALS(1U, rollbackSource.searchedIds.count(3));
ASSERT_EQUALS(1U, rollbackSource.searchedIds.count(4));
- AutoGetCollectionForRead acr(_txn.get(), "test.t");
+ AutoGetCollectionForRead acr(_txn.get(), NamespaceString("test.t"));
BSONObj result;
ASSERT(Helpers::findOne(_txn.get(), acr.getCollection(), BSON("_id" << 1), result));
ASSERT_EQUALS(1, result["v"].numberInt()) << result;
diff --git a/src/mongo/db/repl/sync_tail.cpp b/src/mongo/db/repl/sync_tail.cpp
index 08b1ff8164b..57646bd213f 100644
--- a/src/mongo/db/repl/sync_tail.cpp
+++ b/src/mongo/db/repl/sync_tail.cpp
@@ -419,7 +419,7 @@ void prefetchOp(const BSONObj& op) {
// for multiple prefetches if they are for the same database.
const ServiceContext::UniqueOperationContext txnPtr = cc().makeOperationContext();
OperationContext& txn = *txnPtr;
- AutoGetCollectionForRead ctx(&txn, ns);
+ AutoGetCollectionForRead ctx(&txn, NamespaceString(ns));
Database* db = ctx.getDb();
if (db) {
prefetchPagesForReplicatedOp(&txn, db, op);
diff --git a/src/mongo/dbtests/plan_ranking.cpp b/src/mongo/dbtests/plan_ranking.cpp
index 4d91206d198..4dfd45a14fa 100644
--- a/src/mongo/dbtests/plan_ranking.cpp
+++ b/src/mongo/dbtests/plan_ranking.cpp
@@ -44,6 +44,7 @@
#include "mongo/db/index/index_descriptor.h"
#include "mongo/db/json.h"
#include "mongo/db/matcher/extensions_callback_disallow_extensions.h"
+#include "mongo/db/namespace_string.h"
#include "mongo/db/query/get_executor.h"
#include "mongo/db/query/query_knobs.h"
#include "mongo/db/query/query_planner.h"
@@ -103,7 +104,7 @@ public:
* Does NOT take ownership of 'cq'. Caller DOES NOT own the returned QuerySolution*.
*/
QuerySolution* pickBestPlan(CanonicalQuery* cq) {
- AutoGetCollectionForRead ctx(&_txn, nss.ns());
+ AutoGetCollectionForRead ctx(&_txn, nss);
Collection* collection = ctx.getCollection();
QueryPlannerParams plannerParams;
diff --git a/src/mongo/dbtests/query_plan_executor.cpp b/src/mongo/dbtests/query_plan_executor.cpp
index f91d8fce94a..71492c66683 100644
--- a/src/mongo/dbtests/query_plan_executor.cpp
+++ b/src/mongo/dbtests/query_plan_executor.cpp
@@ -44,6 +44,7 @@
#include "mongo/db/json.h"
#include "mongo/db/matcher/expression_parser.h"
#include "mongo/db/matcher/extensions_callback_disallow_extensions.h"
+#include "mongo/db/namespace_string.h"
#include "mongo/db/pipeline/document_source_cursor.h"
#include "mongo/db/pipeline/expression_context_for_test.h"
#include "mongo/db/pipeline/pipeline.h"
@@ -165,7 +166,7 @@ public:
}
size_t numCursors() {
- AutoGetCollectionForRead ctx(&_txn, nss.ns());
+ AutoGetCollectionForRead ctx(&_txn, nss);
Collection* collection = ctx.getCollection();
if (!collection)
return 0;
@@ -174,7 +175,7 @@ public:
void registerExec(PlanExecutor* exec) {
// TODO: This is not correct (create collection under S-lock)
- AutoGetCollectionForRead ctx(&_txn, nss.ns());
+ AutoGetCollectionForRead ctx(&_txn, nss);
WriteUnitOfWork wunit(&_txn);
Collection* collection = ctx.getDb()->getOrCreateCollection(&_txn, nss.ns());
collection->getCursorManager()->registerExecutor(exec);
@@ -183,7 +184,7 @@ public:
void deregisterExec(PlanExecutor* exec) {
// TODO: This is not correct (create collection under S-lock)
- AutoGetCollectionForRead ctx(&_txn, nss.ns());
+ AutoGetCollectionForRead ctx(&_txn, nss);
WriteUnitOfWork wunit(&_txn);
Collection* collection = ctx.getDb()->getOrCreateCollection(&_txn, nss.ns());
collection->getCursorManager()->deregisterExecutor(exec);
@@ -505,7 +506,7 @@ public:
}
{
- AutoGetCollectionForRead ctx(&_txn, nss.ns());
+ AutoGetCollectionForRead ctx(&_txn, nss);
Collection* collection = ctx.getCollection();
BSONObj filterObj = fromjson("{_id: {$gt: 0}, b: {$gt: 0}}");
diff --git a/src/mongo/dbtests/query_stage_cached_plan.cpp b/src/mongo/dbtests/query_stage_cached_plan.cpp
index 47f73275a45..c940e7c2baa 100644
--- a/src/mongo/dbtests/query_stage_cached_plan.cpp
+++ b/src/mongo/dbtests/query_stage_cached_plan.cpp
@@ -39,6 +39,7 @@
#include "mongo/db/jsobj.h"
#include "mongo/db/json.h"
#include "mongo/db/matcher/extensions_callback_disallow_extensions.h"
+#include "mongo/db/namespace_string.h"
#include "mongo/db/query/canonical_query.h"
#include "mongo/db/query/get_executor.h"
#include "mongo/db/query/plan_cache.h"
@@ -115,7 +116,7 @@ protected:
class QueryStageCachedPlanFailure : public QueryStageCachedPlanBase {
public:
void run() {
- AutoGetCollectionForRead ctx(&_txn, nss.ns());
+ AutoGetCollectionForRead ctx(&_txn, nss);
Collection* collection = ctx.getCollection();
ASSERT(collection);
@@ -183,7 +184,7 @@ public:
class QueryStageCachedPlanHitMaxWorks : public QueryStageCachedPlanBase {
public:
void run() {
- AutoGetCollectionForRead ctx(&_txn, nss.ns());
+ AutoGetCollectionForRead ctx(&_txn, nss);
Collection* collection = ctx.getCollection();
ASSERT(collection);
diff --git a/src/mongo/dbtests/query_stage_collscan.cpp b/src/mongo/dbtests/query_stage_collscan.cpp
index e8825f1bb44..c1dbe116da6 100644
--- a/src/mongo/dbtests/query_stage_collscan.cpp
+++ b/src/mongo/dbtests/query_stage_collscan.cpp
@@ -43,6 +43,7 @@
#include "mongo/db/json.h"
#include "mongo/db/matcher/expression_parser.h"
#include "mongo/db/matcher/extensions_callback_disallow_extensions.h"
+#include "mongo/db/namespace_string.h"
#include "mongo/db/query/plan_executor.h"
#include "mongo/db/storage/record_store.h"
#include "mongo/dbtests/dbtests.h"
@@ -55,6 +56,8 @@ using std::unique_ptr;
using std::vector;
using stdx::make_unique;
+static const NamespaceString nss{"unittests.QueryStageCollectionScan"};
+
//
// Stage-specific tests.
//
@@ -62,26 +65,26 @@ using stdx::make_unique;
class QueryStageCollectionScanBase {
public:
QueryStageCollectionScanBase() : _client(&_txn) {
- OldClientWriteContext ctx(&_txn, ns());
+ OldClientWriteContext ctx(&_txn, nss.ns());
for (int i = 0; i < numObj(); ++i) {
BSONObjBuilder bob;
bob.append("foo", i);
- _client.insert(ns(), bob.obj());
+ _client.insert(nss.ns(), bob.obj());
}
}
virtual ~QueryStageCollectionScanBase() {
- OldClientWriteContext ctx(&_txn, ns());
- _client.dropCollection(ns());
+ OldClientWriteContext ctx(&_txn, nss.ns());
+ _client.dropCollection(nss.ns());
}
void remove(const BSONObj& obj) {
- _client.remove(ns(), obj);
+ _client.remove(nss.ns(), obj);
}
int countResults(CollectionScanParams::Direction direction, const BSONObj& filterObj) {
- AutoGetCollectionForRead ctx(&_txn, ns());
+ AutoGetCollectionForRead ctx(&_txn, nss);
// Configure the scan.
CollectionScanParams params;
@@ -142,10 +145,6 @@ public:
return 50;
}
- static const char* ns() {
- return "unittests.QueryStageCollectionScan";
- }
-
protected:
const ServiceContext::UniqueOperationContext _txnPtr = cc().makeOperationContext();
OperationContext& _txn = *_txnPtr;
@@ -207,7 +206,7 @@ public:
class QueryStageCollscanObjectsInOrderForward : public QueryStageCollectionScanBase {
public:
void run() {
- AutoGetCollectionForRead ctx(&_txn, ns());
+ AutoGetCollectionForRead ctx(&_txn, nss);
// Configure the scan.
CollectionScanParams params;
@@ -243,7 +242,7 @@ public:
class QueryStageCollscanObjectsInOrderBackward : public QueryStageCollectionScanBase {
public:
void run() {
- AutoGetCollectionForRead ctx(&_txn, ns());
+ AutoGetCollectionForRead ctx(&_txn, nss);
CollectionScanParams params;
params.collection = ctx.getCollection();
@@ -277,7 +276,7 @@ public:
class QueryStageCollscanInvalidateUpcomingObject : public QueryStageCollectionScanBase {
public:
void run() {
- OldClientWriteContext ctx(&_txn, ns());
+ OldClientWriteContext ctx(&_txn, nss.ns());
Collection* coll = ctx.getCollection();
@@ -343,7 +342,7 @@ public:
class QueryStageCollscanInvalidateUpcomingObjectBackward : public QueryStageCollectionScanBase {
public:
void run() {
- OldClientWriteContext ctx(&_txn, ns());
+ OldClientWriteContext ctx(&_txn, nss.ns());
Collection* coll = ctx.getCollection();
// Get the RecordIds that would be returned by an in-order scan.
diff --git a/src/mongo/dbtests/query_stage_distinct.cpp b/src/mongo/dbtests/query_stage_distinct.cpp
index 1558f62574a..d0bab154208 100644
--- a/src/mongo/dbtests/query_stage_distinct.cpp
+++ b/src/mongo/dbtests/query_stage_distinct.cpp
@@ -37,6 +37,7 @@
#include "mongo/db/exec/distinct_scan.h"
#include "mongo/db/exec/plan_stage.h"
#include "mongo/db/json.h"
+#include "mongo/db/namespace_string.h"
#include "mongo/db/query/index_bounds_builder.h"
#include "mongo/db/query/plan_executor.h"
#include "mongo/dbtests/dbtests.h"
@@ -47,20 +48,22 @@
namespace QueryStageDistinct {
+static const NamespaceString nss{"unittests.QueryStageDistinct"};
+
class DistinctBase {
public:
DistinctBase() : _client(&_txn) {}
virtual ~DistinctBase() {
- _client.dropCollection(ns());
+ _client.dropCollection(nss.ns());
}
void addIndex(const BSONObj& obj) {
- ASSERT_OK(dbtests::createIndex(&_txn, ns(), obj));
+ ASSERT_OK(dbtests::createIndex(&_txn, nss.ns(), obj));
}
void insert(const BSONObj& obj) {
- _client.insert(ns(), obj);
+ _client.insert(nss.ns(), obj);
}
/**
@@ -90,10 +93,6 @@ public:
return keyElt.numberInt();
}
- static const char* ns() {
- return "unittests.QueryStageDistinct";
- }
-
protected:
const ServiceContext::UniqueOperationContext _txnPtr = cc().makeOperationContext();
OperationContext& _txn = *_txnPtr;
@@ -122,7 +121,7 @@ public:
// Make an index on a:1
addIndex(BSON("a" << 1));
- AutoGetCollectionForRead ctx(&_txn, ns());
+ AutoGetCollectionForRead ctx(&_txn, nss);
Collection* coll = ctx.getCollection();
// Set up the distinct stage.
@@ -189,7 +188,7 @@ public:
// Make an index on a:1
addIndex(BSON("a" << 1));
- AutoGetCollectionForRead ctx(&_txn, ns());
+ AutoGetCollectionForRead ctx(&_txn, nss);
Collection* coll = ctx.getCollection();
// Set up the distinct stage.
@@ -258,7 +257,7 @@ public:
addIndex(BSON("a" << 1 << "b" << 1));
- AutoGetCollectionForRead ctx(&_txn, ns());
+ AutoGetCollectionForRead ctx(&_txn, nss);
Collection* coll = ctx.getCollection();
std::vector<IndexDescriptor*> indices;
diff --git a/src/mongo/dbtests/query_stage_multiplan.cpp b/src/mongo/dbtests/query_stage_multiplan.cpp
index 2f1ea56d50e..2db9a3383fa 100644
--- a/src/mongo/dbtests/query_stage_multiplan.cpp
+++ b/src/mongo/dbtests/query_stage_multiplan.cpp
@@ -42,6 +42,7 @@
#include "mongo/db/json.h"
#include "mongo/db/matcher/expression_parser.h"
#include "mongo/db/matcher/extensions_callback_disallow_extensions.h"
+#include "mongo/db/namespace_string.h"
#include "mongo/db/query/get_executor.h"
#include "mongo/db/query/plan_executor.h"
#include "mongo/db/query/plan_summary_stats.h"
@@ -132,7 +133,7 @@ public:
addIndex(BSON("foo" << 1));
- AutoGetCollectionForRead ctx(&_txn, nss.ns());
+ AutoGetCollectionForRead ctx(&_txn, nss);
const Collection* coll = ctx.getCollection();
// Plan 0: IXScan over foo == 7
@@ -225,7 +226,7 @@ public:
addIndex(BSON("a" << 1));
addIndex(BSON("b" << 1));
- AutoGetCollectionForRead ctx(&_txn, nss.ns());
+ AutoGetCollectionForRead ctx(&_txn, nss);
Collection* collection = ctx.getCollection();
// Query for both 'a' and 'b' and sort on 'b'.
@@ -333,7 +334,7 @@ public:
secondPlan->pushBack(PlanStage::NEED_TIME);
}
- AutoGetCollectionForRead ctx(&_txn, nss.ns());
+ AutoGetCollectionForRead ctx(&_txn, nss);
auto qr = stdx::make_unique<QueryRequest>(nss);
qr->setFilter(BSON("x" << 1));
@@ -408,7 +409,7 @@ public:
addIndex(BSON("foo" << 1));
addIndex(BSON("foo" << -1 << "bar" << 1));
- AutoGetCollectionForRead ctx(&_txn, nss.ns());
+ AutoGetCollectionForRead ctx(&_txn, nss);
Collection* coll = ctx.getCollection();
// Create the executor (Matching all documents).
diff --git a/src/mongo/dbtests/query_stage_tests.cpp b/src/mongo/dbtests/query_stage_tests.cpp
index 93ebb697d12..276b9005b3c 100644
--- a/src/mongo/dbtests/query_stage_tests.cpp
+++ b/src/mongo/dbtests/query_stage_tests.cpp
@@ -39,6 +39,7 @@
#include "mongo/db/json.h"
#include "mongo/db/matcher/expression_parser.h"
#include "mongo/db/matcher/extensions_callback_disallow_extensions.h"
+#include "mongo/db/namespace_string.h"
#include "mongo/db/query/plan_executor.h"
#include "mongo/dbtests/dbtests.h"
#include "mongo/stdx/memory.h"
@@ -78,7 +79,7 @@ public:
}
int countResults(const IndexScanParams& params, BSONObj filterObj = BSONObj()) {
- AutoGetCollectionForRead ctx(&_txn, ns());
+ AutoGetCollectionForRead ctx(&_txn, NamespaceString(ns()));
const CollatorInterface* collator = nullptr;
StatusWithMatchExpression statusWithMatcher = MatchExpressionParser::parse(
@@ -116,7 +117,7 @@ public:
}
IndexDescriptor* getIndex(const BSONObj& obj) {
- AutoGetCollectionForRead ctx(&_txn, ns());
+ AutoGetCollectionForRead ctx(&_txn, NamespaceString(ns()));
Collection* collection = ctx.getCollection();
std::vector<IndexDescriptor*> indexes;
collection->getIndexCatalog()->findIndexesByKeyPattern(&_txn, obj, false, &indexes);
diff --git a/src/mongo/dbtests/query_stage_update.cpp b/src/mongo/dbtests/query_stage_update.cpp
index 6d2b2842465..06343ca966b 100644
--- a/src/mongo/dbtests/query_stage_update.cpp
+++ b/src/mongo/dbtests/query_stage_update.cpp
@@ -46,6 +46,7 @@
#include "mongo/db/jsobj.h"
#include "mongo/db/json.h"
#include "mongo/db/matcher/extensions_callback_disallow_extensions.h"
+#include "mongo/db/namespace_string.h"
#include "mongo/db/ops/update_driver.h"
#include "mongo/db/ops/update_lifecycle_impl.h"
#include "mongo/db/ops/update_request.h"
@@ -226,7 +227,7 @@ public:
// Verify the contents of the resulting collection.
{
- AutoGetCollectionForRead ctx(&_txn, nss.ns());
+ AutoGetCollectionForRead ctx(&_txn, nss);
Collection* collection = ctx.getCollection();
vector<BSONObj> objs;
@@ -335,7 +336,7 @@ public:
// Check the contents of the collection.
{
- AutoGetCollectionForRead ctx(&_txn, nss.ns());
+ AutoGetCollectionForRead ctx(&_txn, nss);
Collection* collection = ctx.getCollection();
vector<BSONObj> objs;
diff --git a/src/mongo/dbtests/querytests.cpp b/src/mongo/dbtests/querytests.cpp
index 64ae5ebb1d5..b051620f0fa 100644
--- a/src/mongo/dbtests/querytests.cpp
+++ b/src/mongo/dbtests/querytests.cpp
@@ -43,6 +43,7 @@
#include "mongo/db/index/index_descriptor.h"
#include "mongo/db/json.h"
#include "mongo/db/lasterror.h"
+#include "mongo/db/namespace_string.h"
#include "mongo/db/query/find.h"
#include "mongo/db/service_context.h"
#include "mongo/db/service_context_d.h"
@@ -330,7 +331,7 @@ public:
// Check that the cursor has been removed.
{
- AutoGetCollectionForRead ctx(&_txn, ns);
+ AutoGetCollectionForRead ctx(&_txn, NamespaceString(ns));
ASSERT(0 == ctx.getCollection()->getCursorManager()->numCursors());
}
@@ -378,7 +379,7 @@ public:
// Check that the cursor still exists
{
- AutoGetCollectionForRead ctx(&_txn, ns);
+ AutoGetCollectionForRead ctx(&_txn, NamespaceString(ns));
ASSERT(1 == ctx.getCollection()->getCursorManager()->numCursors());
ASSERT_OK(ctx.getCollection()->getCursorManager()->pinCursor(cursorId).getStatus());
}
@@ -1243,7 +1244,7 @@ public:
}
size_t numCursorsOpen() {
- AutoGetCollectionForRead ctx(&_txn, _ns);
+ AutoGetCollectionForRead ctx(&_txn, NamespaceString(_ns));
Collection* collection = ctx.getCollection();
if (!collection)
return 0;
@@ -1645,7 +1646,7 @@ public:
ClientCursor* clientCursor = 0;
{
- AutoGetCollectionForRead ctx(&_txn, ns());
+ AutoGetCollectionForRead ctx(&_txn, NamespaceString(ns()));
auto clientCursorPin =
unittest::assertGet(ctx.getCollection()->getCursorManager()->pinCursor(cursorId));
clientCursor = clientCursorPin.getCursor();