summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKaloian Manassiev <kaloian.manassiev@mongodb.com>2014-05-01 21:47:12 -0400
committerKaloian Manassiev <kaloian.manassiev@mongodb.com>2014-05-04 17:54:10 -0400
commitef53c2435ea7b041fb06ed30ff3baf0ab8c30466 (patch)
tree028f54200fd61fc97d8f4447013c6f8f0d3b3016
parent8fe31447b9d21521aa8022a24b4b1c27747c2ba5 (diff)
downloadmongo-ef53c2435ea7b041fb06ed30ff3baf0ab8c30466.tar.gz
SERVER-13797 Remove more usages of Client::getContext
This change removes additional usages of Client::getContext and replaces them with passing the database directly.
-rw-r--r--src/mongo/db/catalog/database.cpp6
-rw-r--r--src/mongo/db/catalog/index_catalog.cpp1
-rw-r--r--src/mongo/db/catalog/index_create.cpp2
-rw-r--r--src/mongo/db/commands/find_and_modify.cpp5
-rw-r--r--src/mongo/db/commands/mr.cpp2
-rw-r--r--src/mongo/db/commands/write_commands/batch_executor.cpp4
-rw-r--r--src/mongo/db/dbcommands.cpp4
-rw-r--r--src/mongo/db/dbhelpers.cpp8
-rw-r--r--src/mongo/db/index/btree_based_access_method.cpp2
-rw-r--r--src/mongo/db/index_builder.cpp13
-rw-r--r--src/mongo/db/index_builder.h2
-rw-r--r--src/mongo/db/instance.cpp4
-rw-r--r--src/mongo/db/ops/delete.cpp3
-rw-r--r--src/mongo/db/ops/delete.h3
-rw-r--r--src/mongo/db/ops/delete_executor.cpp10
-rw-r--r--src/mongo/db/ops/delete_executor.h4
-rw-r--r--src/mongo/db/ops/update.cpp13
-rw-r--r--src/mongo/db/ops/update.h6
-rw-r--r--src/mongo/db/ops/update_executor.cpp3
-rw-r--r--src/mongo/db/ops/update_executor.h2
-rw-r--r--src/mongo/db/query/new_find.cpp4
-rw-r--r--src/mongo/db/repl/is_master.h21
-rw-r--r--src/mongo/db/repl/master_slave.cpp2
-rw-r--r--src/mongo/db/repl/oplog.cpp12
-rw-r--r--src/mongo/db/repl/repl_reads_ok.cpp13
-rw-r--r--src/mongo/db/repl/repl_reads_ok.h5
-rw-r--r--src/mongo/db/repl/rs_rollback.cpp10
-rw-r--r--src/mongo/db/ttl.cpp2
-rw-r--r--src/mongo/s/d_state.cpp7
29 files changed, 86 insertions, 87 deletions
diff --git a/src/mongo/db/catalog/database.cpp b/src/mongo/db/catalog/database.cpp
index 660d47676c2..aa2bb78d4a9 100644
--- a/src/mongo/db/catalog/database.cpp
+++ b/src/mongo/db/catalog/database.cpp
@@ -567,7 +567,7 @@ namespace mongo {
return s;
}
- deleteObjects( txn, _indexesName, oldIndexSpec, true, false, true );
+ deleteObjects(txn, this, _indexesName, oldIndexSpec, true, false, true);
}
Top::global.collectionDropped( fromNS.toString() );
@@ -654,7 +654,7 @@ namespace mongo {
_addNamespaceToCatalog( txn, toNSString, newSpec.isEmpty() ? 0 : &newSpec );
- deleteObjects( txn, _namespacesName, BSON( "name" << fromNS ), false, false, true );
+ deleteObjects(txn, this, _namespacesName, BSON("name" << fromNS), false, false, true);
return Status::OK();
}
@@ -808,7 +808,7 @@ namespace mongo {
{
// remove from the system catalog
BSONObj cond = BSON( "name" << ns ); // { name: "colltodropname" }
- deleteObjects( txn, _namespacesName, cond, false, false, true);
+ deleteObjects(txn, this, _namespacesName, cond, false, false, true);
}
// free extents
diff --git a/src/mongo/db/catalog/index_catalog.cpp b/src/mongo/db/catalog/index_catalog.cpp
index 4fc5326e5ef..855637da1f7 100644
--- a/src/mongo/db/catalog/index_catalog.cpp
+++ b/src/mongo/db/catalog/index_catalog.cpp
@@ -934,6 +934,7 @@ namespace mongo {
b.append( "name", indexName );
BSONObj cond = b.obj(); // e.g.: { name: "ts_1", ns: "foo.coll" }
return static_cast<int>( deleteObjects( txn,
+ _collection->_database,
_collection->_database->_indexesName,
cond,
false,
diff --git a/src/mongo/db/catalog/index_create.cpp b/src/mongo/db/catalog/index_create.cpp
index 9171a098875..631dc12ede1 100644
--- a/src/mongo/db/catalog/index_create.cpp
+++ b/src/mongo/db/catalog/index_create.cpp
@@ -288,7 +288,7 @@ namespace mongo {
false /* cappedOk */,
true /* noWarn */,
&toDelete );
- if ( isMaster( ns.c_str() ) ) {
+ if (isMasterNs(ns.c_str())) {
logOp( txn, "d", ns.c_str(), toDelete );
}
diff --git a/src/mongo/db/commands/find_and_modify.cpp b/src/mongo/db/commands/find_and_modify.cpp
index 01663346e66..e6b92512064 100644
--- a/src/mongo/db/commands/find_and_modify.cpp
+++ b/src/mongo/db/commands/find_and_modify.cpp
@@ -215,7 +215,7 @@ namespace mongo {
if ( remove ) {
_appendHelper( result , doc , found , fields );
if ( found ) {
- deleteObjects( &txn, ns , queryModified , true , true );
+ deleteObjects(&txn, cx.db(), ns, queryModified, true, true);
BSONObjBuilder le( result.subobjStart( "lastErrorObject" ) );
le.appendNumber( "n" , 1 );
le.done();
@@ -245,7 +245,8 @@ namespace mongo {
// the shard version below, but for now no
UpdateLifecycleImpl updateLifecycle(false, requestNs);
request.setLifecycle(&updateLifecycle);
- UpdateResult res = mongo::update(&txn, request, &cc().curop()->debug());
+ UpdateResult res =
+ mongo::update(&txn, cx.db(), request, &cc().curop()->debug());
if ( !collection ) {
// collection created by an upsert
collection = cx.db()->getCollection( ns );
diff --git a/src/mongo/db/commands/mr.cpp b/src/mongo/db/commands/mr.cpp
index 95974890ffa..1232fafa27e 100644
--- a/src/mongo/db/commands/mr.cpp
+++ b/src/mongo/db/commands/mr.cpp
@@ -1252,7 +1252,7 @@ namespace mongo {
if (replSet && 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
- if (!isMaster(dbname.c_str())) {
+ if (!isMasterNs(dbname.c_str())) {
errmsg = "not master";
return false;
}
diff --git a/src/mongo/db/commands/write_commands/batch_executor.cpp b/src/mongo/db/commands/write_commands/batch_executor.cpp
index 1539072a08a..02cabcb1c3a 100644
--- a/src/mongo/db/commands/write_commands/batch_executor.cpp
+++ b/src/mongo/db/commands/write_commands/batch_executor.cpp
@@ -1093,7 +1093,7 @@ namespace mongo {
DurTransaction txn;
try {
- UpdateResult res = executor.execute(&txn);
+ UpdateResult res = executor.execute(&txn, ctx.db());
const long long numDocsModified = res.numDocsModified;
const long long numMatched = res.numMatched;
@@ -1156,7 +1156,7 @@ namespace mongo {
DurTransaction txn;
try {
- result->getStats().n = executor.execute(&txn);
+ result->getStats().n = executor.execute(&txn, writeContext.db());
}
catch ( const DBException& ex ) {
status = ex.toStatus();
diff --git a/src/mongo/db/dbcommands.cpp b/src/mongo/db/dbcommands.cpp
index f980c83e6df..985dae4ea0d 100644
--- a/src/mongo/db/dbcommands.cpp
+++ b/src/mongo/db/dbcommands.cpp
@@ -1551,7 +1551,7 @@ namespace mongo {
}
bool canRunHere =
- isMaster( dbname.c_str() ) ||
+ isMasterNs(dbname.c_str()) ||
c->slaveOk() ||
( c->slaveOverrideOk() && ( queryOptions & QueryOption_SlaveOk ) ) ||
fromRepl;
@@ -1562,7 +1562,7 @@ namespace mongo {
return;
}
- if ( ! c->maintenanceOk() && theReplSet && ! isMaster( dbname.c_str() ) && ! theReplSet->isSecondary() ) {
+ if ( ! c->maintenanceOk() && theReplSet && ! isMasterNs( dbname.c_str() ) && ! theReplSet->isSecondary() ) {
result.append( "note" , "from execCommand" );
appendCommandStatus(result, false, "node is recovering");
return;
diff --git a/src/mongo/db/dbhelpers.cpp b/src/mongo/db/dbhelpers.cpp
index 1f5381fe45c..0e218ca7be9 100644
--- a/src/mongo/db/dbhelpers.cpp
+++ b/src/mongo/db/dbhelpers.cpp
@@ -238,7 +238,7 @@ namespace mongo {
UpdateLifecycleImpl updateLifecycle(true, requestNs);
request.setLifecycle(&updateLifecycle);
- update(txn, request, &debug);
+ update(txn, context.db(), request, &debug);
}
void Helpers::putSingleton(TransactionExperiment* txn, const char *ns, BSONObj obj) {
@@ -254,7 +254,7 @@ namespace mongo {
UpdateLifecycleImpl updateLifecycle(true, requestNs);
request.setLifecycle(&updateLifecycle);
- update(txn, request, &debug);
+ update(txn, context.db(), request, &debug);
context.getClient()->curop()->done();
}
@@ -271,7 +271,7 @@ namespace mongo {
request.setUpsert();
request.setUpdateOpLog(logTheOp);
- update(txn, request, &debug);
+ update(txn, context.db(), request, &debug);
context.getClient()->curop()->done();
}
@@ -554,7 +554,7 @@ namespace mongo {
void Helpers::emptyCollection(TransactionExperiment* txn, const char *ns) {
Client::Context context(ns);
- deleteObjects(txn, ns, BSONObj(), false);
+ deleteObjects(txn, context.db(), ns, BSONObj(), false);
}
Helpers::RemoveSaver::RemoveSaver( const string& a , const string& b , const string& why)
diff --git a/src/mongo/db/index/btree_based_access_method.cpp b/src/mongo/db/index/btree_based_access_method.cpp
index 400041282b5..17d3ada92ff 100644
--- a/src/mongo/db/index/btree_based_access_method.cpp
+++ b/src/mongo/db/index/btree_based_access_method.cpp
@@ -89,7 +89,7 @@ namespace mongo {
if (ErrorCodes::KeyTooLong == status.code()) {
// Ignore this error if we're on a secondary.
- if (!isMaster(NULL)) {
+ if (!isMasterNs(collection()->ns().ns().c_str())) {
continue;
}
diff --git a/src/mongo/db/index_builder.cpp b/src/mongo/db/index_builder.cpp
index 8f6ff9c6051..2bea4ef36ed 100644
--- a/src/mongo/db/index_builder.cpp
+++ b/src/mongo/db/index_builder.cpp
@@ -31,6 +31,7 @@
#include "mongo/db/client.h"
#include "mongo/db/curop.h"
#include "mongo/db/catalog/database.h"
+#include "mongo/db/catalog/database_holder.h"
#include "mongo/db/d_concurrency.h"
#include "mongo/db/repl/rs.h"
#include "mongo/db/storage/mmap_v1/dur_transaction.h"
@@ -64,7 +65,9 @@ namespace mongo {
Client::WriteContext ctx(ns.getSystemIndexesCollection());
DurTransaction txn;
- Status status = build(&txn, ctx.ctx());
+ Database* db = dbHolder().get(ns.db().toString(), storageGlobalParams.dbpath);
+
+ Status status = build(&txn, db);
if ( !status.isOK() ) {
log() << "IndexBuilder could not build index: " << status.toString();
}
@@ -72,11 +75,9 @@ namespace mongo {
cc().shutdown();
}
- Status IndexBuilder::build(TransactionExperiment* txn,
- Client::Context& context ) const {
+ Status IndexBuilder::build(TransactionExperiment* txn, Database* db) const {
+ const string ns = _index["ns"].String();
- string ns = _index["ns"].String();
- Database* db = context.db();
Collection* c = db->getCollection( ns );
if ( !c ) {
c = db->getOrCreateCollection( ns );
@@ -84,7 +85,7 @@ namespace mongo {
}
// Show which index we're building in the curop display.
- context.getClient()->curop()->setQuery(_index);
+ cc().curop()->setQuery(_index);
Status status = c->getIndexCatalog()->createIndex( txn,
_index,
diff --git a/src/mongo/db/index_builder.h b/src/mongo/db/index_builder.h
index a6705b0542f..82b7b6bfd98 100644
--- a/src/mongo/db/index_builder.h
+++ b/src/mongo/db/index_builder.h
@@ -55,7 +55,7 @@ namespace mongo {
*/
virtual std::string name() const;
- Status build(TransactionExperiment* txn, Client::Context& context ) const;
+ Status build(TransactionExperiment* txn, Database* db) const;
/**
* Kill all in-progress indexes matching criteria, if non-empty:
diff --git a/src/mongo/db/instance.cpp b/src/mongo/db/instance.cpp
index 4b47dc50396..ea3f193bf52 100644
--- a/src/mongo/db/instance.cpp
+++ b/src/mongo/db/instance.cpp
@@ -608,7 +608,7 @@ namespace mongo {
Client::Context ctx( ns );
DurTransaction txn;
- UpdateResult res = executor.execute(&txn);
+ UpdateResult res = executor.execute(&txn, ctx.db());
// for getlasterror
lastError.getSafe()->recordUpdate( res.existing , res.numMatched , res.upserted );
@@ -648,7 +648,7 @@ namespace mongo {
Client::Context ctx(ns);
DurTransaction txn;
- long long n = executor.execute(&txn);
+ long long n = executor.execute(&txn, ctx.db());
lastError.getSafe()->recordDelete( n );
op.debug().ndeleted = n;
}
diff --git a/src/mongo/db/ops/delete.cpp b/src/mongo/db/ops/delete.cpp
index 9401fc908a3..1e28a895855 100644
--- a/src/mongo/db/ops/delete.cpp
+++ b/src/mongo/db/ops/delete.cpp
@@ -39,6 +39,7 @@ namespace mongo {
god: allow access to system namespaces, and don't yield
*/
long long deleteObjects(TransactionExperiment* txn,
+ Database* db,
const StringData& ns,
BSONObj pattern,
bool justOne,
@@ -51,7 +52,7 @@ namespace mongo {
request.setUpdateOpLog(logop);
request.setGod(god);
DeleteExecutor executor(&request);
- return executor.execute(txn);
+ return executor.execute(txn, db);
}
} // namespace mongo
diff --git a/src/mongo/db/ops/delete.h b/src/mongo/db/ops/delete.h
index a7472637f2d..28327c42c06 100644
--- a/src/mongo/db/ops/delete.h
+++ b/src/mongo/db/ops/delete.h
@@ -32,12 +32,15 @@
#include "mongo/db/jsobj.h"
+
namespace mongo {
+ class Database;
class TransactionExperiment;
// If justOne is true, deletedId is set to the id of the deleted object.
long long deleteObjects(TransactionExperiment* txn,
+ Database* db,
const StringData& ns,
BSONObj pattern,
bool justOne,
diff --git a/src/mongo/db/ops/delete_executor.cpp b/src/mongo/db/ops/delete_executor.cpp
index fd79e0db5f9..894ce1e9940 100644
--- a/src/mongo/db/ops/delete_executor.cpp
+++ b/src/mongo/db/ops/delete_executor.cpp
@@ -31,7 +31,6 @@
#include "mongo/db/ops/delete_executor.h"
#include "mongo/db/catalog/collection.h"
-#include "mongo/db/catalog/database.h"
#include "mongo/db/client.h"
#include "mongo/db/curop.h"
#include "mongo/db/ops/delete_request.h"
@@ -80,7 +79,7 @@ namespace mongo {
return status;
}
- long long DeleteExecutor::execute(TransactionExperiment* txn) {
+ long long DeleteExecutor::execute(TransactionExperiment* txn, Database* db) {
uassertStatusOK(prepare());
uassert(17417,
mongoutils::str::stream() <<
@@ -100,13 +99,6 @@ namespace mongo {
}
}
- Database* db = currentClient.get()->getContext()->db();
-
- massert(17418,
- mongoutils::str::stream() <<
- "dbname = " << db->name() <<
- "; ns = " << ns.ns(),
- db->name() == nsToDatabaseSubstring(ns.ns()));
Collection* collection = db->getCollection(ns.ns());
if (NULL == collection) {
return 0;
diff --git a/src/mongo/db/ops/delete_executor.h b/src/mongo/db/ops/delete_executor.h
index 4f998f61fc8..ee072d957ad 100644
--- a/src/mongo/db/ops/delete_executor.h
+++ b/src/mongo/db/ops/delete_executor.h
@@ -33,9 +33,11 @@
#include "mongo/base/disallow_copying.h"
#include "mongo/base/status.h"
+
namespace mongo {
class CanonicalQuery;
+ class Database;
class DeleteRequest;
class TransactionExperiment;
@@ -90,7 +92,7 @@ namespace mongo {
*
* Returns the number of documents deleted.
*/
- long long execute(TransactionExperiment* txn);
+ long long execute(TransactionExperiment* txn, Database* db);
private:
/// Unowned pointer to the request object that this executor will process.
diff --git a/src/mongo/db/ops/update.cpp b/src/mongo/db/ops/update.cpp
index 773ecf5a479..33e082f8d32 100644
--- a/src/mongo/db/ops/update.cpp
+++ b/src/mongo/db/ops/update.cpp
@@ -37,6 +37,7 @@
#include "mongo/bson/mutable/algorithm.h"
#include "mongo/bson/mutable/document.h"
#include "mongo/client/dbclientinterface.h"
+#include "mongo/db/catalog/database_holder.h"
#include "mongo/db/clientcursor.h"
#include "mongo/db/index_set.h"
#include "mongo/db/ops/update_driver.h"
@@ -401,8 +402,10 @@ namespace mongo {
"Demoted from primary while performing update on " << nsString.ns());
}
+ Database* db = dbHolder().get(nsString.db().toString(), storageGlobalParams.dbpath);
+
Collection* oldCollection = collection;
- collection = cc().getContext()->db()->getCollection(nsString.ns());
+ collection = db->getCollection(nsString.ns());
// We should not get a new pointer to the same collection...
if (oldCollection && (oldCollection != collection))
@@ -480,15 +483,17 @@ namespace mongo {
} // namespace
UpdateResult update(TransactionExperiment* txn,
+ Database* db,
const UpdateRequest& request,
OpDebug* opDebug) {
UpdateExecutor executor(&request, opDebug);
- return executor.execute(txn);
+ return executor.execute(txn, db);
}
UpdateResult update(
TransactionExperiment* txn,
+ Database* db,
const UpdateRequest& request,
OpDebug* opDebug,
UpdateDriver* driver,
@@ -500,7 +505,8 @@ namespace mongo {
const NamespaceString& nsString = request.getNamespaceString();
UpdateLifecycle* lifecycle = request.getLifecycle();
const CurOp* curOp = cc().curop();
- Collection* collection = cc().getContext()->db()->getCollection(nsString.ns());
+
+ Collection* collection = db->getCollection(nsString.ns());
validateUpdate(nsString.ns().c_str(), request.getUpdates(), request.getQuery());
@@ -860,7 +866,6 @@ namespace mongo {
// Only create the collection if the doc will be inserted.
if (!collection) {
- Database* db = cc().getContext()->db();
collection = db->getCollection(request.getNamespaceString().ns());
if (!collection) {
collection = db->createCollection(txn, request.getNamespaceString().ns());
diff --git a/src/mongo/db/ops/update.h b/src/mongo/db/ops/update.h
index 89550f674cd..cdb76718f3e 100644
--- a/src/mongo/db/ops/update.h
+++ b/src/mongo/db/ops/update.h
@@ -46,7 +46,10 @@ namespace mongo {
*
* Caller must hold the appropriate database locks.
*/
- UpdateResult update(TransactionExperiment* txn, const UpdateRequest& request, OpDebug* opDebug);
+ UpdateResult update(TransactionExperiment* txn,
+ Database* db,
+ const UpdateRequest& request,
+ OpDebug* opDebug);
/**
* Execute the update described by "request", using the given already-parsed
@@ -57,6 +60,7 @@ namespace mongo {
* TODO: Move this into a private method of UpdateExecutor.
*/
UpdateResult update(TransactionExperiment* txn,
+ Database* db,
const UpdateRequest& request,
OpDebug* opDebug,
UpdateDriver* driver,
diff --git a/src/mongo/db/ops/update_executor.cpp b/src/mongo/db/ops/update_executor.cpp
index 9abd39b6016..87b4d43e195 100644
--- a/src/mongo/db/ops/update_executor.cpp
+++ b/src/mongo/db/ops/update_executor.cpp
@@ -62,9 +62,10 @@ namespace mongo {
return Status::OK();
}
- UpdateResult UpdateExecutor::execute(TransactionExperiment* txn) {
+ UpdateResult UpdateExecutor::execute(TransactionExperiment* txn, Database* db) {
uassertStatusOK(prepare());
return update(txn,
+ db,
*_request,
_opDebug,
&_driver,
diff --git a/src/mongo/db/ops/update_executor.h b/src/mongo/db/ops/update_executor.h
index 8c168202db7..ef2ca7ba503 100644
--- a/src/mongo/db/ops/update_executor.h
+++ b/src/mongo/db/ops/update_executor.h
@@ -91,7 +91,7 @@ namespace mongo {
* Execute an update. Requires the caller to hold the database lock on the
* appropriate resources for the request.
*/
- UpdateResult execute(TransactionExperiment* txn);
+ UpdateResult execute(TransactionExperiment* txn, Database* db);
private:
/**
diff --git a/src/mongo/db/query/new_find.cpp b/src/mongo/db/query/new_find.cpp
index 25ffb9b042d..4ac697959fc 100644
--- a/src/mongo/db/query/new_find.cpp
+++ b/src/mongo/db/query/new_find.cpp
@@ -155,7 +155,7 @@ namespace mongo {
// passing in a query object (necessary to check SlaveOK query option), the only state where
// reads are allowed is PRIMARY (or master in master/slave). This function uasserts if
// reads are not okay.
- replVerifyReadsOk();
+ replVerifyReadsOk(ns, NULL);
// A pin performs a CC lookup and if there is a CC, increments the CC's pin value so it
// doesn't time out. Also informs ClientCursor that there is somebody actively holding the
@@ -514,7 +514,7 @@ namespace mongo {
killCurrentOp.checkForInterrupt(); // May trigger maxTimeAlwaysTimeOut fail point.
// uassert if we are not on a primary, and not a secondary with SlaveOk query parameter set.
- replVerifyReadsOk(&pq);
+ replVerifyReadsOk(cq->ns(), &pq);
// If this exists, the collection is sharded.
// If it doesn't exist, we can assume we're not sharded.
diff --git a/src/mongo/db/repl/is_master.h b/src/mongo/db/repl/is_master.h
index 9236a7b9567..dc52d5b092b 100644
--- a/src/mongo/db/repl/is_master.h
+++ b/src/mongo/db/repl/is_master.h
@@ -37,14 +37,10 @@
namespace mongo {
- /* note we always return true for the "local" namespace.
-
- we should not allow most operations when not the master
+ /* We should not allow most operations when not the master
also we report not master if we are "dead".
See also CmdIsMaster.
-
- If 'client' is not specified, the current client is used.
*/
inline bool _isMaster() {
if( replSet ) {
@@ -70,20 +66,7 @@ namespace mongo {
return false;
}
- inline bool isMaster(const char * dbname = 0) {
- if( _isMaster() )
- return true;
- if ( ! dbname ) {
- // XXX: remove this magic and make dbname required?
- if ( cc().getContext() ) {
- Database *database = cc().getContext()->db();
- if ( database ) {
- dbname = database->name().c_str();
- }
- }
- }
- return strcmp( dbname, "local" ) == 0;
- }
+
inline bool isMasterNs( const char *ns ) {
if ( _isMaster() )
return true;
diff --git a/src/mongo/db/repl/master_slave.cpp b/src/mongo/db/repl/master_slave.cpp
index dd08d1099ca..9a3e825eb40 100644
--- a/src/mongo/db/repl/master_slave.cpp
+++ b/src/mongo/db/repl/master_slave.cpp
@@ -204,7 +204,7 @@ namespace mongo {
request.setUpdates(o);
request.setUpsert();
- UpdateResult res = update(&txn, request, &debug);
+ UpdateResult res = update(&txn, ctx.db(), request, &debug);
verify( ! res.modifiers );
verify( res.numMatched == 1 );
diff --git a/src/mongo/db/repl/oplog.cpp b/src/mongo/db/repl/oplog.cpp
index 5de7788a091..12a335411fe 100644
--- a/src/mongo/db/repl/oplog.cpp
+++ b/src/mongo/db/repl/oplog.cpp
@@ -563,10 +563,8 @@ namespace mongo {
builder->go();
}
else {
- Client::Context* ctx = cc().getContext();
- verify( ctx );
IndexBuilder builder(o);
- Status status = builder.build(txn, *ctx);
+ Status status = builder.build(txn, db);
if ( status.isOK() ) {
// yay
}
@@ -602,7 +600,7 @@ namespace mongo {
UpdateLifecycleImpl updateLifecycle(true, requestNs);
request.setLifecycle(&updateLifecycle);
- update(txn, request, &debug);
+ update(txn, db, request, &debug);
if( t.millis() >= 2 ) {
RARELY OCCASIONALLY log() << "warning, repl doing slow updates (no _id field) for " << ns << endl;
@@ -631,7 +629,7 @@ namespace mongo {
UpdateLifecycleImpl updateLifecycle(true, requestNs);
request.setLifecycle(&updateLifecycle);
- update(txn, request, &debug);
+ update(txn, db, request, &debug);
}
}
}
@@ -658,7 +656,7 @@ namespace mongo {
UpdateLifecycleImpl updateLifecycle(true, requestNs);
request.setLifecycle(&updateLifecycle);
- UpdateResult ur = update(txn, request, &debug);
+ UpdateResult ur = update(txn, db, request, &debug);
if( ur.numMatched == 0 ) {
if( ur.modifiers ) {
@@ -699,7 +697,7 @@ namespace mongo {
else if ( *opType == 'd' ) {
opCounters->gotDelete();
if ( opType[1] == 0 )
- deleteObjects(txn, ns, o, /*justOne*/ valueB);
+ deleteObjects(txn, db, ns, o, /*justOne*/ valueB);
else
verify( opType[1] == 'b' ); // "db" advertisement
}
diff --git a/src/mongo/db/repl/repl_reads_ok.cpp b/src/mongo/db/repl/repl_reads_ok.cpp
index 2448cc412ea..6bec81ffbe9 100644
--- a/src/mongo/db/repl/repl_reads_ok.cpp
+++ b/src/mongo/db/repl/repl_reads_ok.cpp
@@ -38,11 +38,11 @@
namespace mongo {
/** we allow queries to SimpleSlave's */
- void replVerifyReadsOk(const LiteParsedQuery* pq) {
+ void replVerifyReadsOk(const std::string& ns, const LiteParsedQuery* pq) {
if( replSet ) {
// todo: speed up the secondary case. as written here there are 2 mutex entries, it
// can b 1.
- if( isMaster() ) return;
+ if (isMasterNs(ns.c_str())) return;
if ( cc().isGod() ) return;
uassert(NotMasterNoSlaveOkCode, "not master and slaveOk=false",
@@ -54,10 +54,11 @@ namespace mongo {
else {
// master/slave
uassert(NotMaster,
- "not master",
- isMaster() ||
- (!pq || pq->hasOption(QueryOption_SlaveOk)) ||
- replSettings.slave == SimpleSlave );
+ "not master",
+ isMasterNs(ns.c_str()) ||
+ pq == NULL ||
+ pq->hasOption(QueryOption_SlaveOk) ||
+ replSettings.slave == SimpleSlave );
}
}
diff --git a/src/mongo/db/repl/repl_reads_ok.h b/src/mongo/db/repl/repl_reads_ok.h
index 73f5ebd484f..492e8b55c78 100644
--- a/src/mongo/db/repl/repl_reads_ok.h
+++ b/src/mongo/db/repl/repl_reads_ok.h
@@ -28,11 +28,14 @@
#pragma once
+#include <string>
+
+
namespace mongo {
class LiteParsedQuery;
// Check to see if slaveOk reads are allowed,
// based on read preference and query options
- void replVerifyReadsOk(const LiteParsedQuery* pq = 0);
+ void replVerifyReadsOk(const std::string& ns, const LiteParsedQuery* pq);
}
diff --git a/src/mongo/db/repl/rs_rollback.cpp b/src/mongo/db/repl/rs_rollback.cpp
index 20b2e8ba8fb..93c9e2306fb 100644
--- a/src/mongo/db/repl/rs_rollback.cpp
+++ b/src/mongo/db/repl/rs_rollback.cpp
@@ -546,7 +546,13 @@ namespace mongo {
else {
try {
deletes++;
- deleteObjects(&txn, d.ns, pattern, /*justone*/true, /*logop*/false, /*god*/true);
+ deleteObjects(&txn,
+ c.db(),
+ d.ns,
+ pattern,
+ true, /*justone*/
+ false, /*logop*/
+ true); /*god*/
}
catch(...) {
log() << "replSet error rollback delete failed ns:" << d.ns << rsLog;
@@ -589,7 +595,7 @@ namespace mongo {
UpdateLifecycleImpl updateLifecycle(true, requestNs);
request.setLifecycle(&updateLifecycle);
- update(&txn, request, &debug);
+ update(&txn, c.db(), request, &debug);
}
}
diff --git a/src/mongo/db/ttl.cpp b/src/mongo/db/ttl.cpp
index dcccb9b4d2f..d7b73a97fda 100644
--- a/src/mongo/db/ttl.cpp
+++ b/src/mongo/db/ttl.cpp
@@ -134,7 +134,7 @@ namespace mongo {
continue;
}
- n = deleteObjects( &txn, ns , query , false , true );
+ n = deleteObjects(&txn, ctx.ctx().db(), ns, query, false, true);
ttlDeletedDocuments.increment( n );
}
diff --git a/src/mongo/s/d_state.cpp b/src/mongo/s/d_state.cpp
index 11908278118..0f3ae665be0 100644
--- a/src/mongo/s/d_state.cpp
+++ b/src/mongo/s/d_state.cpp
@@ -982,7 +982,7 @@ namespace mongo {
}
// we can run on a slave up to here
- if ( ! isMaster( "admin" ) ) {
+ if (!_isMaster()) {
result.append( "errmsg" , "not master" );
result.append( "note" , "from post init in setShardVersion" );
return false;
@@ -1039,10 +1039,7 @@ namespace mongo {
}
// step 4
-
- // this is because of a weird segfault I saw and I can't see why this should ever be set
- massert( 13647 , str::stream() << "context should be empty here, is: " << cc().getContext()->ns() , cc().getContext() == 0 );
-
+
if ( oldVersion.isSet() && ! globalVersion.isSet() ) {
// this had been reset
info->setVersion( ns , ChunkVersion( 0, OID() ) );