summaryrefslogtreecommitdiff
path: root/src/mongo/db/client.cpp
diff options
context:
space:
mode:
authorTyler Brock <tyler.brock@gmail.com>2014-06-30 15:08:13 -0400
committerTyler Brock <tyler.brock@gmail.com>2014-06-30 15:08:13 -0400
commita353e16805d573af3d5ab4d32fbda87ec98d5c40 (patch)
treeb380194417fd18d7ac24a138cf8a3f14f2535e0c /src/mongo/db/client.cpp
parente9a6e9365cf4d6d13b4a3f94aec1f433dab9f704 (diff)
downloadmongo-a353e16805d573af3d5ab4d32fbda87ec98d5c40.tar.gz
Revert "SERVER-13961 Add OperationContext argument to Client::Context"
This reverts commit e1f5a39b1b625d04752be13f39c774e579b64cd8.
Diffstat (limited to 'src/mongo/db/client.cpp')
-rw-r--r--src/mongo/db/client.cpp72
1 files changed, 30 insertions, 42 deletions
diff --git a/src/mongo/db/client.cpp b/src/mongo/db/client.cpp
index 6cfefce96a6..fb87dc5b9a7 100644
--- a/src/mongo/db/client.cpp
+++ b/src/mongo/db/client.cpp
@@ -54,7 +54,7 @@
#include "mongo/db/instance.h"
#include "mongo/db/json.h"
#include "mongo/db/jsobj.h"
-#include "mongo/db/operation_context.h"
+#include "mongo/db/operation_context_impl.h"
#include "mongo/db/repl/repl_coordinator_global.h"
#include "mongo/db/repl/rs.h"
#include "mongo/db/storage_options.h"
@@ -162,27 +162,23 @@ namespace mongo {
}
BSONObj CachedBSONObjBase::_tooBig = fromjson("{\"$msg\":\"query not recording (too large)\"}");
-
- Client::Context::Context(OperationContext* txn, const std::string& ns, Database * db)
- : _client( currentClient.get() ),
- _justCreated(false),
- _doVersion( true ),
- _ns( ns ),
- _db(db),
- _txn(txn) {
+ Client::Context::Context(const std::string& ns , Database * db) :
+ _client( currentClient.get() ),
+ _justCreated(false),
+ _doVersion( true ),
+ _ns( ns ),
+ _db(db)
+ {
}
- Client::Context::Context(OperationContext* txn,
- const string& ns,
- bool doVersion)
- : _client( currentClient.get() ),
- _justCreated(false), // set for real in finishInit
- _doVersion(doVersion),
- _ns( ns ),
- _db(NULL),
- _txn(txn) {
-
+ Client::Context::Context(const string& ns, bool doVersion) :
+ _client( currentClient.get() ),
+ _justCreated(false), // set for real in finishInit
+ _doVersion(doVersion),
+ _ns( ns ),
+ _db(0)
+ {
_finishInit();
}
@@ -195,7 +191,7 @@ namespace mongo {
_lk.reset(new Lock::DBRead(txn->lockState(), ns));
Database *db = dbHolder().get(txn, ns);
if( db ) {
- _c.reset(new Context(txn, ns, db, doVersion));
+ _c.reset(new Context(ns, db, doVersion));
return;
}
}
@@ -206,18 +202,18 @@ namespace mongo {
if (txn->lockState()->isW()) {
// write locked already
DEV RARELY log() << "write locked on ReadContext construction " << ns << endl;
- _c.reset(new Context(txn, ns, doVersion));
+ _c.reset(new Context(ns, doVersion));
}
else if (!txn->lockState()->isRecursive()) {
_lk.reset(0);
{
Lock::GlobalWrite w(txn->lockState());
- Context c(txn, ns, doVersion);
+ Context c(ns, doVersion);
}
// db could be closed at this interim point -- that is ok, we will throw, and don't mind throwing.
_lk.reset(new Lock::DBRead(txn->lockState(), ns));
- _c.reset(new Context(txn, ns, doVersion));
+ _c.reset(new Context(ns, doVersion));
}
else {
uasserted(15928, str::stream() << "can't open a database from a nested read lock " << ns);
@@ -232,8 +228,7 @@ namespace mongo {
Client::WriteContext::WriteContext(
OperationContext* opCtx, const std::string& ns, bool doVersion)
: _lk(opCtx->lockState(), ns),
- _c(opCtx, ns, doVersion) {
-
+ _c(ns, doVersion) {
}
@@ -257,24 +252,21 @@ namespace mongo {
}
// invoked from ReadContext
- Client::Context::Context(OperationContext* txn,
- const string& ns,
- Database *db,
- bool doVersion)
- : _client( currentClient.get() ),
- _justCreated(false),
- _doVersion( doVersion ),
- _ns( ns ),
- _db(db),
- _txn(txn) {
-
+ Client::Context::Context(const string& ns, Database *db, bool doVersion) :
+ _client( currentClient.get() ),
+ _justCreated(false),
+ _doVersion( doVersion ),
+ _ns( ns ),
+ _db(db)
+ {
verify(_db);
if (_doVersion) checkNotStale();
_client->_curOp->enter( this );
}
void Client::Context::_finishInit() {
- _db = dbHolder().getOrCreate(_txn, _ns, _justCreated);
+ OperationContextImpl txn; // TODO get rid of this once reads require transactions
+ _db = dbHolder().getOrCreate(&txn, _ns, _justCreated);
invariant(_db);
if( _doVersion ) checkNotStale();
@@ -284,11 +276,7 @@ namespace mongo {
Client::Context::~Context() {
DEV verify( _client == currentClient.get() );
-
- // Lock must still be held
- invariant(_txn->lockState()->isLocked());
-
- _client->_curOp->recordGlobalTime(_txn->lockState()->isWriteLocked(), _timer.micros());
+ _client->_curOp->recordGlobalTime( _timer.micros() );
}
void Client::appendLastOp( BSONObjBuilder& b ) const {