summaryrefslogtreecommitdiff
path: root/src/mongo/db
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/db')
-rw-r--r--src/mongo/db/SConscript1
-rw-r--r--src/mongo/db/catalog/index_create.cpp3
-rw-r--r--src/mongo/db/clientcursor.cpp8
-rw-r--r--src/mongo/db/clientlistplugin.cpp13
-rw-r--r--src/mongo/db/commands/current_op.cpp9
-rw-r--r--src/mongo/db/commands/getmore_cmd.cpp6
-rw-r--r--src/mongo/db/commands/write_commands/batch_executor.cpp9
-rw-r--r--src/mongo/db/curop.cpp77
-rw-r--r--src/mongo/db/curop.h33
-rw-r--r--src/mongo/db/curop_test.cpp7
-rw-r--r--src/mongo/db/db.cpp2
-rw-r--r--src/mongo/db/dbdirectclient.cpp2
-rw-r--r--src/mongo/db/dbwebserver.cpp2
-rw-r--r--src/mongo/db/index_builder.cpp2
-rw-r--r--src/mongo/db/instance.cpp7
-rw-r--r--src/mongo/db/introspect.cpp1
-rw-r--r--src/mongo/db/operation_context.cpp46
-rw-r--r--src/mongo/db/operation_context.h23
-rw-r--r--src/mongo/db/operation_context_impl.cpp34
-rw-r--r--src/mongo/db/operation_context_impl.h8
-rw-r--r--src/mongo/db/operation_context_noop.h35
-rw-r--r--src/mongo/db/query/find.cpp2
-rw-r--r--src/mongo/db/query/find.h4
-rw-r--r--src/mongo/db/range_deleter.cpp14
-rw-r--r--src/mongo/db/range_deleter_db_env.cpp2
-rw-r--r--src/mongo/db/repl/SConscript1
-rw-r--r--src/mongo/db/repl/bgsync.cpp5
-rw-r--r--src/mongo/db/repl/master_slave.cpp4
-rw-r--r--src/mongo/db/repl/operation_context_repl_mock.cpp25
-rw-r--r--src/mongo/db/repl/operation_context_repl_mock.h11
-rw-r--r--src/mongo/db/repl/replication_coordinator_impl_test.cpp10
-rw-r--r--src/mongo/db/repl/sync_source_feedback.cpp6
-rw-r--r--src/mongo/db/repl/sync_tail.cpp2
-rw-r--r--src/mongo/db/repl/sync_tail_test.cpp14
-rw-r--r--src/mongo/db/service_context.h4
-rw-r--r--src/mongo/db/service_context_d.cpp15
-rw-r--r--src/mongo/db/service_context_d.h2
-rw-r--r--src/mongo/db/service_context_noop.cpp5
-rw-r--r--src/mongo/db/service_context_noop.h2
-rw-r--r--src/mongo/db/storage/SConscript1
-rw-r--r--src/mongo/db/storage/mmap_v1/SConscript4
-rw-r--r--src/mongo/db/storage/mmap_v1/data_file_sync.cpp1
42 files changed, 241 insertions, 221 deletions
diff --git a/src/mongo/db/SConscript b/src/mongo/db/SConscript
index d1cb5273109..da65f0978c2 100644
--- a/src/mongo/db/SConscript
+++ b/src/mongo/db/SConscript
@@ -387,7 +387,6 @@ env.Library(
source=[
'client.cpp',
'client_basic.cpp',
- 'operation_context.cpp',
'service_context.cpp',
'service_context_noop.cpp',
],
diff --git a/src/mongo/db/catalog/index_create.cpp b/src/mongo/db/catalog/index_create.cpp
index 3eee9cae3b6..c069b0cc292 100644
--- a/src/mongo/db/catalog/index_create.cpp
+++ b/src/mongo/db/catalog/index_create.cpp
@@ -42,7 +42,6 @@
#include "mongo/db/audit.h"
#include "mongo/db/background.h"
#include "mongo/db/catalog/collection.h"
-#include "mongo/db/client.h"
#include "mongo/db/clientcursor.h"
#include "mongo/db/concurrency/write_conflict_exception.h"
#include "mongo/db/curop.h"
@@ -229,7 +228,7 @@ namespace mongo {
invariant(_indexes.size() == 1);
invariant(_buildInBackground);
IndexDescriptor* descriptor = _indexes[0].block->getEntry()->descriptor();
- _collection->getIndexCatalog()->registerIndexBuild(descriptor, _txn->getOpID());
+ _collection->getIndexCatalog()->registerIndexBuild(descriptor, CurOp::get(_txn)->opNum());
return descriptor;
}
diff --git a/src/mongo/db/clientcursor.cpp b/src/mongo/db/clientcursor.cpp
index 84fe0017e18..3a0af5d615f 100644
--- a/src/mongo/db/clientcursor.cpp
+++ b/src/mongo/db/clientcursor.cpp
@@ -293,11 +293,9 @@ namespace mongo {
Timer t;
const int Secs = 4;
while (!inShutdown()) {
- {
- OperationContextImpl txn;
- cursorStatsTimedOut.increment(
- CursorManager::timeoutCursorsGlobal(&txn, t.millisReset()));
- }
+ OperationContextImpl txn;
+ cursorStatsTimedOut.increment(
+ CursorManager::timeoutCursorsGlobal(&txn, t.millisReset()));
sleepsecs(Secs);
}
}
diff --git a/src/mongo/db/clientlistplugin.cpp b/src/mongo/db/clientlistplugin.cpp
index 6eb854c739d..89f0f5788f1 100644
--- a/src/mongo/db/clientlistplugin.cpp
+++ b/src/mongo/db/clientlistplugin.cpp
@@ -101,8 +101,8 @@ namespace {
ss << "<tr><td>" << client->desc() << "</td>";
- tablecell(ss, txn->getOpID());
- tablecell(ss, true);
+ tablecell(ss, curOp->opNum());
+ tablecell(ss, curOp->active());
// LockState
{
@@ -115,7 +115,12 @@ namespace {
tablecell(ss, lockerInfoBuilder.obj());
}
- tablecell(ss, curOp->elapsedSeconds());
+ if (curOp->active()) {
+ tablecell(ss, curOp->elapsedSeconds());
+ }
+ else {
+ tablecell(ss, "");
+ }
tablecell(ss, curOp->getOp());
tablecell(ss, html::escape(curOp->getNS()));
@@ -205,9 +210,7 @@ namespace {
client->reportState(b);
const OperationContext* txn = client->getOperationContext();
- b.appendBool("active", static_cast<bool>(txn));
if (txn) {
- b.append("opid", txn->getOpID());
// CurOp
if (CurOp::get(txn)) {
diff --git a/src/mongo/db/commands/current_op.cpp b/src/mongo/db/commands/current_op.cpp
index b26c811d2d8..402558814df 100644
--- a/src/mongo/db/commands/current_op.cpp
+++ b/src/mongo/db/commands/current_op.cpp
@@ -113,6 +113,9 @@ namespace mongo {
// Skip over inactive connections.
if (!opCtx)
continue;
+ auto curOp = CurOp::get(opCtx);
+ if (!curOp || !curOp->active())
+ continue;
}
BSONObjBuilder infoBuilder;
@@ -121,9 +124,7 @@ namespace mongo {
client->reportState(infoBuilder);
// Operation context specific information
- infoBuilder.appendBool("active", static_cast<bool>(opCtx));
if (opCtx) {
- infoBuilder.append("opid", opCtx->getOpID());
// CurOp
if (CurOp::get(opCtx)) {
CurOp::get(opCtx)->reportState(&infoBuilder);
@@ -134,6 +135,10 @@ namespace mongo {
opCtx->lockState()->getLockerInfo(&lockerInfo);
fillLockerInfo(lockerInfo, infoBuilder);
}
+ else {
+ // If no operation context, mark the operation as inactive
+ infoBuilder.append("active", false);
+ }
infoBuilder.done();
diff --git a/src/mongo/db/commands/getmore_cmd.cpp b/src/mongo/db/commands/getmore_cmd.cpp
index f0fbdad5163..91dcffe3a4f 100644
--- a/src/mongo/db/commands/getmore_cmd.cpp
+++ b/src/mongo/db/commands/getmore_cmd.cpp
@@ -37,18 +37,16 @@
#include "mongo/db/auth/authorization_session.h"
#include "mongo/db/catalog/collection.h"
#include "mongo/db/catalog/cursor_manager.h"
-#include "mongo/db/client.h"
#include "mongo/db/clientcursor.h"
#include "mongo/db/commands.h"
#include "mongo/db/commands/cursor_responses.h"
-#include "mongo/db/curop.h"
#include "mongo/db/db_raii.h"
#include "mongo/db/exec/working_set_common.h"
#include "mongo/db/global_timestamp.h"
-#include "mongo/db/query/find.h"
-#include "mongo/db/query/getmore_request.h"
#include "mongo/db/repl/oplog.h"
#include "mongo/db/service_context.h"
+#include "mongo/db/query/find.h"
+#include "mongo/db/query/getmore_request.h"
#include "mongo/db/stats/counters.h"
#include "mongo/util/log.h"
#include "mongo/util/scopeguard.h"
diff --git a/src/mongo/db/commands/write_commands/batch_executor.cpp b/src/mongo/db/commands/write_commands/batch_executor.cpp
index 3d3ca64cfb1..c698c352e50 100644
--- a/src/mongo/db/commands/write_commands/batch_executor.cpp
+++ b/src/mongo/db/commands/write_commands/batch_executor.cpp
@@ -896,8 +896,7 @@ namespace mongo {
WriteErrorDetail** error ) {
// BEGIN CURRENT OP
- CurOp currentOp(_txn);
- currentOp.setOp(dbUpdate);
+ CurOp currentOp(_txn->getClient(), dbUpdate);
beginCurrentOp( &currentOp, _txn->getClient(), updateItem );
incOpStats( updateItem );
@@ -941,8 +940,7 @@ namespace mongo {
// Removes are similar to updates, but page faults are handled externally
// BEGIN CURRENT OP
- CurOp currentOp(_txn);
- currentOp.setOp(dbDelete);
+ CurOp currentOp(_txn->getClient(), dbDelete);
beginCurrentOp( &currentOp, _txn->getClient(), removeItem );
incOpStats( removeItem );
@@ -1137,8 +1135,7 @@ namespace mongo {
void WriteBatchExecutor::execOneInsert(ExecInsertsState* state, WriteErrorDetail** error) {
BatchItemRef currInsertItem(state->request, state->currIndex);
- CurOp currentOp(_txn);
- currentOp.setOp(dbInsert);
+ CurOp currentOp(_txn->getClient(), dbInsert);
beginCurrentOp( &currentOp, _txn->getClient(), currInsertItem );
incOpStats(currInsertItem);
diff --git a/src/mongo/db/curop.cpp b/src/mongo/db/curop.cpp
index 4c41b5bd365..640c82063e0 100644
--- a/src/mongo/db/curop.cpp
+++ b/src/mongo/db/curop.cpp
@@ -56,10 +56,10 @@ namespace mongo {
*
* The stack itself is represented in the _parent pointers of the CurOp class.
*/
- class CurOp::CurOpStack {
- MONGO_DISALLOW_COPYING(CurOpStack);
+ class CurOp::ClientCuropStack {
+ MONGO_DISALLOW_COPYING(ClientCuropStack);
public:
- CurOpStack() : _base(nullptr, this) {}
+ ClientCuropStack() : _base(nullptr, this) {}
/**
* Returns the top of the CurOp stack.
@@ -69,15 +69,15 @@ namespace mongo {
/**
* Adds "curOp" to the top of the CurOp stack for a client. Called by CurOp's constructor.
*/
- void push(OperationContext* opCtx, CurOp* curOp) {
- invariant(opCtx);
- if (_opCtx) {
- invariant(_opCtx == opCtx);
+ void push(Client* client, CurOp* curOp) {
+ invariant(client);
+ if (_client) {
+ invariant(_client == client);
}
else {
- _opCtx = opCtx;
+ _client = client;
}
- boost::lock_guard<Client> lk(*_opCtx->getClient());
+ boost::lock_guard<Client> lk(*_client);
push_nolock(curOp);
}
@@ -101,20 +101,20 @@ namespace mongo {
// the client during the final pop.
const bool shouldLock = _top->_parent;
if (shouldLock) {
- invariant(_opCtx);
- _opCtx->getClient()->lock();
+ invariant(_client);
+ _client->lock();
}
invariant(_top);
CurOp* retval = _top;
_top = _top->_parent;
if (shouldLock) {
- _opCtx->getClient()->unlock();
+ _client->unlock();
}
return retval;
}
private:
- OperationContext* _opCtx = nullptr;
+ Client* _client = nullptr;
// Top of the stack of CurOps for a Client.
CurOp* _top = nullptr;
@@ -123,8 +123,8 @@ namespace mongo {
const CurOp _base;
};
- const OperationContext::Decoration<CurOp::CurOpStack> CurOp::_curopStack =
- OperationContext::declareDecoration<CurOp::CurOpStack>();
+ const Client::Decoration<CurOp::ClientCuropStack> CurOp::_curopStack =
+ Client::declareDecoration<CurOp::ClientCuropStack>();
// Enabling the maxTimeAlwaysTimeOut fail point will cause any query or command run with a
// valid non-zero max time to fail immediately. Any getmore operation on a cursor already
@@ -146,18 +146,33 @@ namespace mongo {
CurOp* CurOp::get(const OperationContext* opCtx) { return get(*opCtx); }
- CurOp* CurOp::get(const OperationContext& opCtx) { return _curopStack(opCtx).top(); }
+ CurOp* CurOp::get(const OperationContext& opCtx) {
+ return _curopStack(opCtx.getClient()).top();
+ }
- CurOp::CurOp(OperationContext* opCtx) : CurOp(opCtx, &_curopStack(opCtx)) {}
+ CurOp::CurOp(Client* client) : CurOp(client, &_curopStack(client)) {}
- CurOp::CurOp(OperationContext* opCtx, CurOpStack* stack) : _stack(stack) {
- if (opCtx) {
- _stack->push(opCtx, this);
+ CurOp::CurOp(Client* client, ClientCuropStack* stack) : _stack(stack) {
+ if (client) {
+ _stack->push(client, this);
}
else {
_stack->push_nolock(this);
}
_start = 0;
+ _active = false;
+ _reset();
+ _op = 0;
+ _opNum = _nextOpNum.fetchAndAdd(1);
+ _command = NULL;
+ }
+
+ CurOp::CurOp(Client* client, int op) : CurOp(client, &_curopStack(client)) {
+ _op = op;
+ _active = true;
+ }
+
+ void CurOp::_reset() {
_isCommand = false;
_dbprofile = 0;
_end = 0;
@@ -168,11 +183,20 @@ namespace mongo {
_killPending.store(0);
_numYields = 0;
_expectedLatencyMs = 0;
- _op = 0;
- _command = NULL;
}
- void CurOp::setOp(int op) {
+ void CurOp::reset() {
+ _reset();
+ _start = 0;
+ _opNum = _nextOpNum.fetchAndAdd(1);
+ _ns = "";
+ _debug.reset();
+ _query.reset();
+ _active = true; // this should be last for ui clarity
+ }
+
+ void CurOp::reset(int op) {
+ reset();
_op = op;
}
@@ -230,8 +254,11 @@ namespace mongo {
}
void CurOp::reportState(BSONObjBuilder* builder) {
+ builder->append("opid", _opNum);
+ bool a = _active && _start;
+ builder->append("active", a);
- if (_start) {
+ if( a ) {
builder->append("secs_running", elapsedSeconds() );
builder->append("microsecs_running", static_cast<long long int>(elapsedMicros()) );
}
@@ -385,6 +412,8 @@ namespace mongo {
}
+ AtomicUInt32 CurOp::_nextOpNum;
+
static Counter64 returnedCounter;
static Counter64 insertedCounter;
static Counter64 updatedCounter;
diff --git a/src/mongo/db/curop.h b/src/mongo/db/curop.h
index f58ee576370..66201f53fdd 100644
--- a/src/mongo/db/curop.h
+++ b/src/mongo/db/curop.h
@@ -34,7 +34,7 @@
#include <boost/noncopyable.hpp>
#include "mongo/base/disallow_copying.h"
-#include "mongo/db/operation_context.h"
+#include "mongo/db/client.h"
#include "mongo/db/server_options.h"
#include "mongo/platform/atomic_word.h"
#include "mongo/util/concurrency/spin_lock.h"
@@ -198,7 +198,8 @@ namespace mongo {
static CurOp* get(const OperationContext* opCtx);
static CurOp* get(const OperationContext& opCtx);
- explicit CurOp(OperationContext* client);
+ explicit CurOp(Client* client);
+ CurOp(Client* client, int op);
~CurOp();
bool haveQuery() const { return _query.have(); }
@@ -206,11 +207,8 @@ namespace mongo {
void appendQuery( BSONObjBuilder& b , StringData name ) const { _query.append( b , name ); }
void enter(const char* ns, int dbProfileLevel);
-
- /**
- * Sets the type of the current operation to "op".
- */
- void setOp(int op);
+ void reset();
+ void reset(int op);
void markCommand() { _isCommand = true; }
OpDebug& debug() { return _debug; }
std::string getNS() const { return _ns.toString(); }
@@ -222,6 +220,11 @@ namespace mongo {
return _dbprofile >= 2 || ms >= serverGlobalParams.slowMS;
}
+ unsigned int opNum() const { return _opNum; }
+
+ /** if this op is running */
+ bool active() const { return _active; }
+
int getOp() const { return _op; }
//
@@ -268,11 +271,12 @@ namespace mongo {
return _start;
}
void done() {
+ _active = false;
_end = curTimeMicros64();
}
long long totalTimeMicros() {
- massert( 12601 , "CurOp not marked done yet" , _end );
+ massert( 12601 , "CurOp not marked done yet" , ! _active );
return _end - startTime();
}
int totalTimeMillis() { return (int) (totalTimeMicros() / 1000); }
@@ -317,20 +321,25 @@ namespace mongo {
void setNS( StringData ns );
private:
- class CurOpStack;
+ class ClientCuropStack;
+
+ static const Client::Decoration<ClientCuropStack> _curopStack;
- static const OperationContext::Decoration<CurOpStack> _curopStack;
+ CurOp(Client*, ClientCuropStack*);
- CurOp(OperationContext*, CurOpStack*);
+ void _reset();
- CurOpStack* _stack;
+ static AtomicUInt32 _nextOpNum;
+ ClientCuropStack* _stack;
CurOp* _parent = nullptr;
Command * _command;
long long _start;
long long _end;
+ bool _active;
int _op;
bool _isCommand;
int _dbprofile; // 0=off, 1=slow, 2=all
+ unsigned int _opNum;
ThreadSafeString _ns;
CachedBSONObj<512> _query; // CachedBSONObj is thread safe
OpDebug _debug;
diff --git a/src/mongo/db/curop_test.cpp b/src/mongo/db/curop_test.cpp
index 1f4f58153eb..17ac612c3a3 100644
--- a/src/mongo/db/curop_test.cpp
+++ b/src/mongo/db/curop_test.cpp
@@ -33,7 +33,6 @@
#include "mongo/base/init.h"
#include "mongo/db/client.h"
#include "mongo/db/curop.h"
-#include "mongo/db/operation_context_noop.h"
#include "mongo/db/service_context.h"
#include "mongo/db/service_context_noop.h"
#include "mongo/stdx/memory.h"
@@ -78,8 +77,7 @@ namespace mongo {
TEST(TimeHasExpired, PosSimple) {
auto service = stdx::make_unique<ServiceContextNoop>();
auto client = service->makeClient("CurOpTest");
- OperationContextNoop txn(client.get(), 100);
- CurOp curOp(&txn);
+ CurOp curOp(client.get());
curOp.setMaxTimeMicros(intervalShort);
curOp.ensureStarted();
sleepmicros(intervalLong);
@@ -90,8 +88,7 @@ namespace mongo {
TEST(TimeHasExpired, NegSimple) {
auto service = stdx::make_unique<ServiceContextNoop>();
auto client = service->makeClient("CurOpTest");
- OperationContextNoop txn(client.get(), 100);
- CurOp curOp(&txn);
+ CurOp curOp(client.get());
curOp.setMaxTimeMicros(intervalLong);
curOp.ensureStarted();
sleepmicros(intervalShort);
diff --git a/src/mongo/db/db.cpp b/src/mongo/db/db.cpp
index 61678070dcf..d7e69a0c5ca 100644
--- a/src/mongo/db/db.cpp
+++ b/src/mongo/db/db.cpp
@@ -157,13 +157,13 @@ namespace mongo {
}
virtual void process(Message& m , AbstractMessagingPort* port) {
+ OperationContextImpl txn;
while ( true ) {
if ( inShutdown() ) {
log() << "got request after shutdown()" << endl;
break;
}
- OperationContextImpl txn;
DbResponse dbresponse;
assembleResponse(&txn, m, dbresponse, port->remote());
diff --git a/src/mongo/db/dbdirectclient.cpp b/src/mongo/db/dbdirectclient.cpp
index f0107baf9ce..3aee1750172 100644
--- a/src/mongo/db/dbdirectclient.cpp
+++ b/src/mongo/db/dbdirectclient.cpp
@@ -126,7 +126,6 @@ namespace mongo {
LastError::get(_txn->getClient()).startRequest();
DbResponse dbResponse;
- CurOp curOp(_txn);
assembleResponse(_txn, toSend, dbResponse, dummyHost);
verify(dbResponse.response);
@@ -142,7 +141,6 @@ namespace mongo {
LastError::get(_txn->getClient()).startRequest();
DbResponse dbResponse;
- CurOp curOp(_txn);
assembleResponse(_txn, toSend, dbResponse, dummyHost);
}
diff --git a/src/mongo/db/dbwebserver.cpp b/src/mongo/db/dbwebserver.cpp
index bd12f09e255..ed5bf9f2192 100644
--- a/src/mongo/db/dbwebserver.cpp
+++ b/src/mongo/db/dbwebserver.cpp
@@ -314,7 +314,7 @@ namespace {
vector<string>& headers,
const SockAddr &from) {
- auto txn = getGlobalServiceContext()->newOpCtx();
+ boost::scoped_ptr<OperationContext> txn(getGlobalServiceContext()->newOpCtx());
if (url.size() > 1) {
diff --git a/src/mongo/db/index_builder.cpp b/src/mongo/db/index_builder.cpp
index 45620ee0544..7baf390792d 100644
--- a/src/mongo/db/index_builder.cpp
+++ b/src/mongo/db/index_builder.cpp
@@ -87,7 +87,7 @@ namespace {
AuthorizationSession::get(txn.getClient())->grantInternalAuthorization();
- CurOp::get(txn)->setOp(dbInsert);
+ CurOp::get(txn)->reset(dbInsert);
NamespaceString ns(_index["ns"].String());
ScopedTransaction transaction(&txn, MODE_IX);
diff --git a/src/mongo/db/instance.cpp b/src/mongo/db/instance.cpp
index c1927347377..f5399564d6e 100644
--- a/src/mongo/db/instance.cpp
+++ b/src/mongo/db/instance.cpp
@@ -516,8 +516,13 @@ namespace {
break;
}
+ scoped_ptr<CurOp> nestedOp;
+ if (CurOp::get(txn)->active()) {
+ nestedOp.reset(new CurOp(&c));
+ }
+
CurOp& currentOp = *CurOp::get(txn);
- currentOp.setOp(op);
+ currentOp.reset(op);
OpDebug& debug = currentOp.debug();
debug.op = op;
diff --git a/src/mongo/db/introspect.cpp b/src/mongo/db/introspect.cpp
index 9354f8cd3ca..1f6e0003e6c 100644
--- a/src/mongo/db/introspect.cpp
+++ b/src/mongo/db/introspect.cpp
@@ -37,7 +37,6 @@
#include "mongo/db/auth/authorization_session.h"
#include "mongo/db/auth/user_set.h"
#include "mongo/db/catalog/collection.h"
-#include "mongo/db/client.h"
#include "mongo/db/curop.h"
#include "mongo/db/db_raii.h"
#include "mongo/db/jsobj.h"
diff --git a/src/mongo/db/operation_context.cpp b/src/mongo/db/operation_context.cpp
deleted file mode 100644
index 5c87bee7220..00000000000
--- a/src/mongo/db/operation_context.cpp
+++ /dev/null
@@ -1,46 +0,0 @@
-/**
- * Copyright (C) 2015 MongoDB Inc.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- * As a special exception, the copyright holders give permission to link the
- * code of portions of this program with the OpenSSL library under certain
- * conditions as described in each individual source file and distribute
- * linked combinations including the program with the OpenSSL library. You
- * must comply with the GNU Affero General Public License in all respects for
- * all of the code used other than as permitted herein. If you modify file(s)
- * with this exception, you may extend this exception to your version of the
- * file(s), but you are not obligated to do so. If you do not wish to do so,
- * delete this exception statement from your version. If you delete this
- * exception statement from all source files in the program, then also delete
- * it in the license file.
- */
-
-#include "mongo/platform/basic.h"
-
-#include "mongo/db/operation_context.h"
-
-#include "mongo/util/assert_util.h"
-
-namespace mongo {
-
- OperationContext::OperationContext(Client* client, unsigned int opId, Locker* locker) :
- _client(client), _opId(opId), _locker(locker) {
- }
-
- Client* OperationContext::getClient() const {
- invariant(_client);
- return _client;
- }
-
-} // namespace mongo
diff --git a/src/mongo/db/operation_context.h b/src/mongo/db/operation_context.h
index e3c28ef2c05..0717745e858 100644
--- a/src/mongo/db/operation_context.h
+++ b/src/mongo/db/operation_context.h
@@ -31,6 +31,7 @@
#include "mongo/base/disallow_copying.h"
#include "mongo/base/status.h"
#include "mongo/db/storage/recovery_unit.h"
+#include "mongo/db/concurrency/locker.h"
#include "mongo/db/concurrency/d_concurrency.h"
#include "mongo/db/write_concern_options.h"
#include "mongo/util/decorable.h"
@@ -39,7 +40,6 @@ namespace mongo {
class Client;
class CurOp;
- class Locker;
class ProgressMeter;
class StringData;
class WriteUnitOfWork;
@@ -68,7 +68,7 @@ namespace mongo {
kFailedUnitOfWork // in a unit of work that has failed and must be aborted
};
- virtual ~OperationContext() = default;
+ virtual ~OperationContext() { }
/**
* Interface for durability. Caller DOES NOT own pointer.
@@ -101,7 +101,7 @@ namespace mongo {
/**
* Interface for locking. Caller DOES NOT own pointer.
*/
- Locker* lockState() const { return _locker; }
+ virtual Locker* lockState() const = 0;
// --- operation level info? ---
@@ -132,14 +132,16 @@ namespace mongo {
/**
* Returns the client under which this context runs.
*/
- Client* getClient() const;
+ virtual Client* getClient() const = 0;
virtual uint64_t getRemainingMaxTimeMicros() const = 0;
/**
* Returns the operation ID associated with this operation.
+ * WARNING: Due to SERVER-14995, this OpID is not guaranteed to stay the same for the
+ * lifetime of this OperationContext.
*/
- unsigned int getOpID() const { return _opId; }
+ virtual unsigned int getOpID() const = 0;
/**
* @return true if this instance is primary for this namespace
@@ -168,21 +170,12 @@ namespace mongo {
virtual bool writesAreReplicated() const = 0;
protected:
- OperationContext(Client* client,
- unsigned int opId,
- Locker* locker);
+ OperationContext() { }
RecoveryUnitState _ruState = kNotInUnitOfWork;
private:
friend class WriteUnitOfWork;
- Client* const _client;
- const unsigned int _opId;
-
- // The lifetime of locker is managed by subclasses of OperationContext, so it is not
- // safe to access _locker in the destructor of OperationContext.
- Locker* const _locker;
-
WriteConcernOptions _writeConcern;
};
diff --git a/src/mongo/db/operation_context_impl.cpp b/src/mongo/db/operation_context_impl.cpp
index 6eccefce706..b57090e04b9 100644
--- a/src/mongo/db/operation_context_impl.cpp
+++ b/src/mongo/db/operation_context_impl.cpp
@@ -69,30 +69,28 @@ namespace {
const auto clientOperationInfoDecoration = Client::declareDecoration<ClientOperationInfo>();
- AtomicUInt32 nextOpId{1};
} // namespace
using std::string;
OperationContextImpl::OperationContextImpl()
- : OperationContext(&cc(),
- nextOpId.fetchAndAdd(1),
- clientOperationInfoDecoration(cc()).getLocker()),
+ : _client(&cc()),
+ _locker(clientOperationInfoDecoration(_client).getLocker()),
_writesAreReplicated(true) {
+ invariant(_locker);
+
StorageEngine* storageEngine = getGlobalServiceContext()->getGlobalStorageEngine();
_recovery.reset(storageEngine->newRecoveryUnit());
- auto client = getClient();
- stdx::lock_guard<Client> lk(*client);
- client->setOperationContext(this);
+ stdx::lock_guard<Client> lk(*_client);
+ _client->setOperationContext(this);
}
OperationContextImpl::~OperationContextImpl() {
- lockState()->assertEmptyAndReset();
- auto client = getClient();
- stdx::lock_guard<Client> lk(*client);
- client->resetOperationContext();
+ _locker->assertEmptyAndReset();
+ stdx::lock_guard<Client> lk(*_client);
+ _client->resetOperationContext();
}
RecoveryUnit* OperationContextImpl::recoveryUnit() const {
@@ -115,6 +113,10 @@ namespace {
return oldState;
}
+ Locker* OperationContextImpl::lockState() const {
+ return _locker;
+ }
+
ProgressMeter* OperationContextImpl::setMessage(const char * msg,
const std::string &name,
unsigned long long progressMeterTotal,
@@ -126,6 +128,14 @@ namespace {
return CurOp::get(this)->getNS();
}
+ Client* OperationContextImpl::getClient() const {
+ return _client;
+ }
+
+ unsigned int OperationContextImpl::getOpID() const {
+ return CurOp::get(this)->opNum();
+ }
+
uint64_t OperationContextImpl::getRemainingMaxTimeMicros() const {
return CurOp::get(this)->getRemainingMaxTimeMicros();
}
@@ -198,7 +208,7 @@ namespace {
if (opShouldFail(this, scopedFailPoint.getData())) {
log() << "set pending kill on "
<< (curOp->parent() ? "nested" : "top-level")
- << " op " << getOpID() << ", for checkForInterruptFail";
+ << " op " << curOp->opNum() << ", for checkForInterruptFail";
curOp->kill();
}
}
diff --git a/src/mongo/db/operation_context_impl.h b/src/mongo/db/operation_context_impl.h
index 362455581fd..a904400648a 100644
--- a/src/mongo/db/operation_context_impl.h
+++ b/src/mongo/db/operation_context_impl.h
@@ -47,6 +47,8 @@ namespace mongo {
virtual RecoveryUnitState setRecoveryUnit(RecoveryUnit* unit,
RecoveryUnitState state) override;
+ virtual Locker* lockState() const override;
+
virtual ProgressMeter* setMessage(const char* msg,
const std::string& name,
unsigned long long progressMeterTotal,
@@ -54,6 +56,10 @@ namespace mongo {
virtual std::string getNS() const override;
+ virtual Client* getClient() const override;
+
+ virtual unsigned int getOpID() const override;
+
virtual uint64_t getRemainingMaxTimeMicros() const override;
virtual void checkForInterrupt() const override;
@@ -66,6 +72,8 @@ namespace mongo {
private:
std::auto_ptr<RecoveryUnit> _recovery;
+ Client* const _client; // cached, not owned
+ Locker* const _locker; // cached, not owned
bool _writesAreReplicated;
};
diff --git a/src/mongo/db/operation_context_noop.h b/src/mongo/db/operation_context_noop.h
index 254f553445b..a428042438c 100644
--- a/src/mongo/db/operation_context_noop.h
+++ b/src/mongo/db/operation_context_noop.h
@@ -39,32 +39,25 @@ namespace mongo {
class OperationContextNoop : public OperationContext {
public:
+ OperationContextNoop(RecoveryUnit* ru)
+ : _recoveryUnit(ru),
+ _locker(new LockerNoop()) {
- OperationContextNoop() : OperationContextNoop(new RecoveryUnitNoop()) {}
-
- OperationContextNoop(RecoveryUnit* ru) : OperationContextNoop(nullptr, 0, ru) {}
-
- OperationContextNoop(Client* client, unsigned int opId)
- : OperationContextNoop(client, opId, new RecoveryUnitNoop()) {
}
- OperationContextNoop(Client* client, unsigned int opId, RecoveryUnit* ru)
- : OperationContextNoop(client, opId, new LockerNoop(), ru) {
- }
+ OperationContextNoop()
+ : _recoveryUnit(new RecoveryUnitNoop()),
+ _locker(new LockerNoop()) {
- OperationContextNoop(Client* client, unsigned int opId, Locker* locker)
- : OperationContextNoop(client, opId, locker, new RecoveryUnitNoop()) {
}
- OperationContextNoop(Client* client, unsigned int opId, Locker* locker, RecoveryUnit* ru)
- : OperationContext(client, opId, locker),
- _recoveryUnit(ru) {
+ virtual ~OperationContextNoop() { }
- _locker.reset(lockState());
+ virtual Client* getClient() const override {
+ invariant(false);
+ return NULL;
}
- virtual ~OperationContextNoop() = default;
-
virtual RecoveryUnit* recoveryUnit() const override {
return _recoveryUnit.get();
}
@@ -81,6 +74,10 @@ namespace mongo {
return oldState;
}
+ virtual Locker* lockState() const override {
+ return _locker.get();
+ }
+
virtual ProgressMeter* setMessage(const char * msg,
const std::string &name,
unsigned long long progressMeterTotal,
@@ -101,6 +98,10 @@ namespace mongo {
return std::string();
};
+ virtual unsigned int getOpID() const override {
+ return 0;
+ }
+
void setReplicatedWrites(bool writesAreReplicated = true) override {}
bool writesAreReplicated() const override {
diff --git a/src/mongo/db/query/find.cpp b/src/mongo/db/query/find.cpp
index eb2b62f8d4a..c1938e51852 100644
--- a/src/mongo/db/query/find.cpp
+++ b/src/mongo/db/query/find.cpp
@@ -37,10 +37,8 @@
#include "mongo/client/dbclientinterface.h"
#include "mongo/db/catalog/collection.h"
#include "mongo/db/catalog/database_holder.h"
-#include "mongo/db/client.h"
#include "mongo/db/clientcursor.h"
#include "mongo/db/commands.h"
-#include "mongo/db/curop.h"
#include "mongo/db/db_raii.h"
#include "mongo/db/exec/filter.h"
#include "mongo/db/exec/working_set_common.h"
diff --git a/src/mongo/db/query/find.h b/src/mongo/db/query/find.h
index 650a6f0e4fd..876070a5fdc 100644
--- a/src/mongo/db/query/find.h
+++ b/src/mongo/db/query/find.h
@@ -31,15 +31,13 @@
#include <string>
#include "mongo/db/clientcursor.h"
+#include "mongo/db/curop.h"
#include "mongo/db/dbmessage.h"
-#include "mongo/db/operation_context.h"
#include "mongo/db/query/canonical_query.h"
#include "mongo/util/net/message.h"
namespace mongo {
- class CurOp;
- class NamespaceString;
class OperationContext;
class ScopedRecoveryUnitSwapper {
diff --git a/src/mongo/db/range_deleter.cpp b/src/mongo/db/range_deleter.cpp
index cb00ad28554..caa2c63804c 100644
--- a/src/mongo/db/range_deleter.cpp
+++ b/src/mongo/db/range_deleter.cpp
@@ -448,6 +448,8 @@ namespace {
while (!inShutdown() && !stopRequested()) {
string errMsg;
+ boost::scoped_ptr<OperationContext> txn(getGlobalServiceContext()->newOpCtx());
+
RangeDeleteEntry* nextTask = NULL;
{
@@ -470,11 +472,12 @@ namespace {
RangeDeleteEntry* entry = *iter;
set<CursorId> cursorsNow;
- if (entry->options.waitForOpenCursors) {
- auto txn = getGlobalServiceContext()->newOpCtx();
- _env->getCursorIds(txn.get(),
- entry->options.range.ns,
- &cursorsNow);
+ {
+ if (entry->options.waitForOpenCursors) {
+ _env->getCursorIds(txn.get(),
+ entry->options.range.ns,
+ &cursorsNow);
+ }
}
set<CursorId> cursorsLeft;
@@ -513,7 +516,6 @@ namespace {
}
{
- auto txn = getGlobalServiceContext()->newOpCtx();
nextTask->stats.deleteStartTS = jsTime();
bool delResult = _env->deleteRange(txn.get(),
*nextTask,
diff --git a/src/mongo/db/range_deleter_db_env.cpp b/src/mongo/db/range_deleter_db_env.cpp
index c84818158c2..a73c1070ca7 100644
--- a/src/mongo/db/range_deleter_db_env.cpp
+++ b/src/mongo/db/range_deleter_db_env.cpp
@@ -90,7 +90,7 @@ namespace mongo {
}
// log the opId so the user can use it to cancel the delete using killOp.
- unsigned int opId = txn->getOpID();
+ unsigned int opId = CurOp::get(txn)->opNum();
log() << "Deleter starting delete for: " << ns
<< " from " << inclusiveLower
<< " -> " << exclusiveUpper
diff --git a/src/mongo/db/repl/SConscript b/src/mongo/db/repl/SConscript
index 9759df2e68d..d7db78aae5c 100644
--- a/src/mongo/db/repl/SConscript
+++ b/src/mongo/db/repl/SConscript
@@ -468,7 +468,6 @@ env.Library(
],
LIBDEPS=[
'task_runner',
- '$BUILD_DIR/mongo/db/service_context',
'$BUILD_DIR/mongo/unittest/concurrency',
'$BUILD_DIR/mongo/util/decorable',
],
diff --git a/src/mongo/db/repl/bgsync.cpp b/src/mongo/db/repl/bgsync.cpp
index 0cfd1834b50..164cb3c99c7 100644
--- a/src/mongo/db/repl/bgsync.cpp
+++ b/src/mongo/db/repl/bgsync.cpp
@@ -184,6 +184,8 @@ namespace {
return;
}
+ OperationContextImpl txn;
+
// We need to wait until initial sync has started.
if (_replCoord->getMyLastOptime().isNull()) {
sleepsecs(1);
@@ -191,8 +193,7 @@ namespace {
}
// we want to unpause when we're no longer primary
// start() also loads _lastOpTimeFetched, which we know is set from the "if"
- OperationContextImpl txn;
- if (_pause) {
+ else if (_pause) {
start(&txn);
}
diff --git a/src/mongo/db/repl/master_slave.cpp b/src/mongo/db/repl/master_slave.cpp
index fde2c24232c..dc975fe7b90 100644
--- a/src/mongo/db/repl/master_slave.cpp
+++ b/src/mongo/db/repl/master_slave.cpp
@@ -695,9 +695,6 @@ namespace repl {
if ( !only.empty() && only != clientName )
return;
- // Push the CurOp stack for "txn" so each individual oplog entry application is separately
- // reported.
- CurOp individualOp(txn);
txn->setReplicatedWrites(false);
const ReplSettings& replSettings = getGlobalReplicationCoordinator()->getSettings();
if (replSettings.pretouch &&
@@ -760,6 +757,7 @@ namespace repl {
// mongos will not send requests there. That's why the last argument is false (do not do
// version checking).
OldClientContext ctx(txn, ns, false);
+ CurOp::get(txn)->reset();
bool empty = !ctx.db()->getDatabaseCatalogEntry()->hasUserData();
bool incompleteClone = incompleteCloneDbs.count( clientName ) != 0;
diff --git a/src/mongo/db/repl/operation_context_repl_mock.cpp b/src/mongo/db/repl/operation_context_repl_mock.cpp
index 10d2e69beca..5cfc9f31713 100644
--- a/src/mongo/db/repl/operation_context_repl_mock.cpp
+++ b/src/mongo/db/repl/operation_context_repl_mock.cpp
@@ -36,20 +36,27 @@
namespace mongo {
namespace repl {
- OperationContextReplMock::OperationContextReplMock() : OperationContextReplMock(0) {}
-
- OperationContextReplMock::OperationContextReplMock(unsigned int opNum) :
- OperationContextReplMock(nullptr, opNum) {
- }
-
- OperationContextReplMock::OperationContextReplMock(Client* client, unsigned int opNum) :
- OperationContextNoop(client, opNum, new MMAPV1LockerImpl()),
+ OperationContextReplMock::OperationContextReplMock():
+ _lockState(new MMAPV1LockerImpl()),
+ _opID(0),
_checkForInterruptStatus(Status::OK()),
_maxTimeMicrosRemaining(0),
_writesAreReplicated(true) {
}
- OperationContextReplMock::~OperationContextReplMock() = default;
+ OperationContextReplMock::~OperationContextReplMock() {}
+
+ Locker* OperationContextReplMock::lockState() const {
+ return _lockState.get();
+ }
+
+ unsigned int OperationContextReplMock::getOpID() const {
+ return _opID;
+ }
+
+ void OperationContextReplMock::setOpID(unsigned int opID) {
+ _opID = opID;
+ }
void OperationContextReplMock::checkForInterrupt() const {
uassertStatusOK(checkForInterruptNoAssert());
diff --git a/src/mongo/db/repl/operation_context_repl_mock.h b/src/mongo/db/repl/operation_context_repl_mock.h
index 6c5e76b046f..6efacdaa68d 100644
--- a/src/mongo/db/repl/operation_context_repl_mock.h
+++ b/src/mongo/db/repl/operation_context_repl_mock.h
@@ -46,10 +46,14 @@ namespace repl {
class OperationContextReplMock : public OperationContextNoop {
public:
OperationContextReplMock();
- explicit OperationContextReplMock(unsigned int opNum);
- OperationContextReplMock(Client* client, unsigned int opNum);
virtual ~OperationContextReplMock();
+ virtual Locker* lockState() const override;
+
+ virtual unsigned int getOpID() const override;
+
+ void setOpID(unsigned int opID);
+
virtual void checkForInterrupt() const override;
virtual Status checkForInterruptNoAssert() const override;
@@ -65,6 +69,9 @@ namespace repl {
bool writesAreReplicated() const override;
private:
+ boost::scoped_ptr<Locker> _lockState;
+ unsigned int _opID;
+
Status _checkForInterruptStatus;
uint64_t _maxTimeMicrosRemaining;
bool _writesAreReplicated;
diff --git a/src/mongo/db/repl/replication_coordinator_impl_test.cpp b/src/mongo/db/repl/replication_coordinator_impl_test.cpp
index 0757f671552..fdde13dbc71 100644
--- a/src/mongo/db/repl/replication_coordinator_impl_test.cpp
+++ b/src/mongo/db/repl/replication_coordinator_impl_test.cpp
@@ -857,8 +857,7 @@ namespace {
TEST_F(ReplCoordTest, AwaitReplicationInterrupt) {
// Tests that a thread blocked in awaitReplication can be killed by a killOp operation
- const unsigned int opID = 100;
- OperationContextReplMock txn{opID};
+ OperationContextReplMock txn;
assertStartSuccess(
BSON("_id" << "mySet" <<
"version" << 2 <<
@@ -879,6 +878,8 @@ namespace {
writeConcern.wTimeout = WriteConcernOptions::kNoTimeout;
writeConcern.wNumNodes = 2;
+ unsigned int opID = 100;
+ txn.setOpID(opID);
// 2 nodes waiting for time2
awaiter.setOpTime(time2);
@@ -1175,8 +1176,7 @@ namespace {
}
TEST_F(StepDownTest, InterruptStepDown) {
- const unsigned int opID = 100;
- OperationContextReplMock txn{opID};
+ OperationContextReplMock txn;
OpTimeWithTermZero optime1(100, 1);
OpTimeWithTermZero optime2(100, 2);
// No secondary is caught up
@@ -1195,6 +1195,8 @@ namespace {
runner.start(&txn);
+ unsigned int opID = 100;
+ txn.setOpID(opID);
txn.setCheckForInterruptStatus(kInterruptedStatus);
getReplCoord()->interrupt(opID);
diff --git a/src/mongo/db/repl/sync_source_feedback.cpp b/src/mongo/db/repl/sync_source_feedback.cpp
index f11e420612a..6773758ef7c 100644
--- a/src/mongo/db/repl/sync_source_feedback.cpp
+++ b/src/mongo/db/repl/sync_source_feedback.cpp
@@ -157,6 +157,7 @@ namespace repl {
void SyncSourceFeedback::run() {
Client::initThread("SyncSourceFeedback");
+ OperationContextImpl txn;
ReplicationCoordinator* replCoord = getGlobalReplicationCoordinator();
while (true) { // breaks once _shutdownSignaled is true
@@ -173,7 +174,6 @@ namespace repl {
_positionChanged = false;
}
- auto txn = cc().getServiceContext()->newOpCtx();
MemberState state = replCoord->getMemberState();
if (state.primary() || state.startup()) {
_resetConnection();
@@ -192,14 +192,14 @@ namespace repl {
_positionChanged = true;
continue;
}
- if (!_connect(txn.get(), target)) {
+ if (!_connect(&txn, target)) {
sleepmillis(500);
boost::unique_lock<boost::mutex> lock(_mtx);
_positionChanged = true;
continue;
}
}
- Status status = updateUpstream(txn.get());
+ Status status = updateUpstream(&txn);
if (!status.isOK()) {
sleepmillis(500);
boost::unique_lock<boost::mutex> lock(_mtx);
diff --git a/src/mongo/db/repl/sync_tail.cpp b/src/mongo/db/repl/sync_tail.cpp
index 350a737ee72..0e690b80c30 100644
--- a/src/mongo/db/repl/sync_tail.cpp
+++ b/src/mongo/db/repl/sync_tail.cpp
@@ -136,7 +136,7 @@ namespace repl {
}
// Count each log op application as a separate operation, for reporting purposes
- CurOp individualOp(txn);
+ CurOp::get(txn)->reset();
const char *ns = op.getStringField("ns");
verify(ns);
diff --git a/src/mongo/db/repl/sync_tail_test.cpp b/src/mongo/db/repl/sync_tail_test.cpp
index 94d1c073007..9e20ce78818 100644
--- a/src/mongo/db/repl/sync_tail_test.cpp
+++ b/src/mongo/db/repl/sync_tail_test.cpp
@@ -64,6 +64,16 @@ namespace {
void BackgroundSyncMock::consume() { }
void BackgroundSyncMock::waitForMore() { }
+ class OperationContextSyncTailMock : public OperationContextReplMock {
+ public:
+ Client* getClient() const override;
+ };
+
+ Client* OperationContextSyncTailMock::getClient() const {
+ Client::initThreadIfNotAlready();
+ return &cc();
+ }
+
class SyncTailTest : public unittest::Test {
public:
SyncTailTest();
@@ -102,9 +112,7 @@ namespace {
replSettings.oplogSize = 5 * 1024 * 1024;
setGlobalReplicationCoordinator(new ReplicationCoordinatorMock(replSettings));
-
- Client::initThreadIfNotAlready();
- _txn.reset(new OperationContextReplMock(&cc(), 0));
+ _txn.reset(new OperationContextSyncTailMock());
_opsApplied = 0;
_applyOp = [](OperationContext* txn,
Database* db,
diff --git a/src/mongo/db/service_context.h b/src/mongo/db/service_context.h
index 675b9dfd1ae..3833ff69d85 100644
--- a/src/mongo/db/service_context.h
+++ b/src/mongo/db/service_context.h
@@ -251,9 +251,9 @@ namespace mongo {
virtual void registerKillOpListener(KillOpListenerInterface* listener) = 0;
/**
- * Returns a new OperationContext.
+ * Returns a new OperationContext. Caller owns pointer.
*/
- virtual std::unique_ptr<OperationContext> newOpCtx() = 0;
+ virtual OperationContext* newOpCtx() = 0;
//
// Global OpObserver.
diff --git a/src/mongo/db/service_context_d.cpp b/src/mongo/db/service_context_d.cpp
index a9b22a986fb..eb00449c625 100644
--- a/src/mongo/db/service_context_d.cpp
+++ b/src/mongo/db/service_context_d.cpp
@@ -227,11 +227,14 @@ namespace mongo {
if (!opCtx) {
return false;
}
- if (opCtx->getOpID() != opId) {
- return false;
+ for( CurOp *k = CurOp::get(opCtx); k; k = k->parent() ) {
+ if ( k->opNum() != opId )
+ continue;
+
+ _killOperation_inlock(opCtx);
+ return true;
}
- _killOperation_inlock(opCtx);
- return true;
+ return false;
}
void ServiceContextMongoD::_killOperation_inlock(OperationContext* opCtx) {
@@ -292,8 +295,8 @@ namespace mongo {
_killOpListeners.push_back(listener);
}
- std::unique_ptr<OperationContext> ServiceContextMongoD::newOpCtx() {
- return stdx::make_unique<OperationContextImpl>();
+ OperationContext* ServiceContextMongoD::newOpCtx() {
+ return new OperationContextImpl();
}
void ServiceContextMongoD::setOpObserver(std::unique_ptr<OpObserver> opObserver) {
diff --git a/src/mongo/db/service_context_d.h b/src/mongo/db/service_context_d.h
index 14ec7dc475d..1d707f33d63 100644
--- a/src/mongo/db/service_context_d.h
+++ b/src/mongo/db/service_context_d.h
@@ -72,7 +72,7 @@ namespace mongo {
void registerKillOpListener(KillOpListenerInterface* listener);
- std::unique_ptr<OperationContext> newOpCtx();
+ OperationContext* newOpCtx();
void setOpObserver(std::unique_ptr<OpObserver> opObserver);
diff --git a/src/mongo/db/service_context_noop.cpp b/src/mongo/db/service_context_noop.cpp
index 87bff0c7932..47c3efe8797 100644
--- a/src/mongo/db/service_context_noop.cpp
+++ b/src/mongo/db/service_context_noop.cpp
@@ -32,7 +32,6 @@
#include "mongo/db/operation_context_noop.h"
#include "mongo/db/op_observer.h"
-#include "mongo/stdx/memory.h"
namespace mongo {
@@ -82,8 +81,8 @@ namespace mongo {
void ServiceContextNoop::registerKillOpListener(KillOpListenerInterface* listener) {
}
- std::unique_ptr<OperationContext> ServiceContextNoop::newOpCtx() {
- return stdx::make_unique<OperationContextNoop>();
+ OperationContext* ServiceContextNoop::newOpCtx() {
+ return new OperationContextNoop();
}
void ServiceContextNoop::setOpObserver(std::unique_ptr<OpObserver> opObserver) {
diff --git a/src/mongo/db/service_context_noop.h b/src/mongo/db/service_context_noop.h
index 833c37f975a..b7f541b784f 100644
--- a/src/mongo/db/service_context_noop.h
+++ b/src/mongo/db/service_context_noop.h
@@ -57,7 +57,7 @@ namespace mongo {
void registerKillOpListener(KillOpListenerInterface* listener);
- std::unique_ptr<OperationContext> newOpCtx();
+ OperationContext* newOpCtx();
void setOpObserver(std::unique_ptr<OpObserver> opObserver);
diff --git a/src/mongo/db/storage/SConscript b/src/mongo/db/storage/SConscript
index 3b9fc94fb35..83d21072778 100644
--- a/src/mongo/db/storage/SConscript
+++ b/src/mongo/db/storage/SConscript
@@ -35,7 +35,6 @@ env.Library(
],
LIBDEPS=[
'$BUILD_DIR/mongo/db/catalog/collection_options',
- '$BUILD_DIR/mongo/db/service_context',
],
)
diff --git a/src/mongo/db/storage/mmap_v1/SConscript b/src/mongo/db/storage/mmap_v1/SConscript
index 841e8f9ce48..c7cbbd07e2c 100644
--- a/src/mongo/db/storage/mmap_v1/SConscript
+++ b/src/mongo/db/storage/mmap_v1/SConscript
@@ -110,7 +110,6 @@ env.Library(
LIBDEPS= [
'extent',
'$BUILD_DIR/mongo/db/commands/server_status_core',
- '$BUILD_DIR/mongo/db/service_context',
'$BUILD_DIR/mongo/util/concurrency/spin_lock',
'$BUILD_DIR/mongo/util/progress_meter',
]
@@ -196,8 +195,7 @@ env.Library(
'btree/key.cpp'
],
LIBDEPS= [
- '$BUILD_DIR/mongo/bson/bson',
- '$BUILD_DIR/mongo/db/service_context',
+ '$BUILD_DIR/mongo/bson/bson'
]
)
diff --git a/src/mongo/db/storage/mmap_v1/data_file_sync.cpp b/src/mongo/db/storage/mmap_v1/data_file_sync.cpp
index 9579278ded1..d4d2cb43fe3 100644
--- a/src/mongo/db/storage/mmap_v1/data_file_sync.cpp
+++ b/src/mongo/db/storage/mmap_v1/data_file_sync.cpp
@@ -32,7 +32,6 @@
#include "mongo/db/storage/mmap_v1/data_file_sync.h"
-#include "mongo/db/client.h"
#include "mongo/db/commands/server_status_metric.h"
#include "mongo/db/service_context.h"
#include "mongo/db/instance.h"