summaryrefslogtreecommitdiff
path: root/src/mongo/db
diff options
context:
space:
mode:
authorAndy Schwerin <schwerin@mongodb.com>2016-04-16 12:24:16 -0400
committerAndy Schwerin <schwerin@mongodb.com>2016-04-18 23:44:56 -0400
commit0ab34aa7b9c3c48ea6cf17888620fca455284d35 (patch)
tree9d592c0427229b53bdea159617f7de5d3c6ff819 /src/mongo/db
parentbdc06761206ac398af04f0a2eb482c4dca49bad8 (diff)
downloadmongo-0ab34aa7b9c3c48ea6cf17888620fca455284d35.tar.gz
SERVER-23779 Replace direct instantiation of OperationContextImpl with cc().makeOperationContext().
Also, make OperationContextImpl's constructor private so that it can only be constructed via a Client.
Diffstat (limited to 'src/mongo/db')
-rw-r--r--src/mongo/db/auth/auth_index_d.cpp6
-rw-r--r--src/mongo/db/catalog/apply_ops.cpp1
-rw-r--r--src/mongo/db/catalog/capped_utils.cpp1
-rw-r--r--src/mongo/db/catalog/drop_collection.cpp1
-rw-r--r--src/mongo/db/catalog/drop_database.cpp1
-rw-r--r--src/mongo/db/clientcursor.cpp4
-rw-r--r--src/mongo/db/commands/clone_collection.cpp1
-rw-r--r--src/mongo/db/commands/collection_to_capped.cpp1
-rw-r--r--src/mongo/db/commands/compact.cpp1
-rw-r--r--src/mongo/db/commands/create_indexes.cpp1
-rw-r--r--src/mongo/db/commands/drop_indexes.cpp1
-rw-r--r--src/mongo/db/commands/fsync.cpp6
-rw-r--r--src/mongo/db/commands/mr.cpp8
-rw-r--r--src/mongo/db/commands/rename_collection_cmd.cpp1
-rw-r--r--src/mongo/db/commands/test_commands.cpp1
-rw-r--r--src/mongo/db/commands/touch.cpp1
-rw-r--r--src/mongo/db/commands/validate.cpp2
-rw-r--r--src/mongo/db/index_builder.cpp4
-rw-r--r--src/mongo/db/index_rebuilder.cpp1
-rw-r--r--src/mongo/db/instance.cpp2
-rw-r--r--src/mongo/db/operation_context_impl.h6
-rw-r--r--src/mongo/db/ops/update.cpp2
-rw-r--r--src/mongo/db/repl/bgsync.cpp4
-rw-r--r--src/mongo/db/repl/initial_sync.cpp6
-rw-r--r--src/mongo/db/repl/master_slave.cpp11
-rw-r--r--src/mongo/db/repl/oplog.cpp12
-rw-r--r--src/mongo/db/repl/replication_coordinator_external_state_impl.cpp1
-rw-r--r--src/mongo/db/repl/replication_info.cpp2
-rw-r--r--src/mongo/db/repl/rs_initialsync.cpp8
-rw-r--r--src/mongo/db/repl/rs_sync.cpp1
-rw-r--r--src/mongo/db/repl/storage_interface_impl.cpp2
-rw-r--r--src/mongo/db/repl/sync_source_feedback.cpp1
-rw-r--r--src/mongo/db/repl/sync_tail.cpp21
-rw-r--r--src/mongo/db/service_context_d.cpp2
-rw-r--r--src/mongo/db/service_context_d_test_fixture.cpp18
-rw-r--r--src/mongo/db/storage/mmap_v1/dur.cpp4
-rw-r--r--src/mongo/db/storage/mmap_v1/dur_recover.cpp6
-rw-r--r--src/mongo/db/storage/mmap_v1/record_store_v1_capped.cpp2
-rw-r--r--src/mongo/db/storage/wiredtiger/wiredtiger_record_store_mongod.cpp4
-rw-r--r--src/mongo/db/ttl.cpp4
40 files changed, 79 insertions, 83 deletions
diff --git a/src/mongo/db/auth/auth_index_d.cpp b/src/mongo/db/auth/auth_index_d.cpp
index 546df4c1da9..ac3d38ebf03 100644
--- a/src/mongo/db/auth/auth_index_d.cpp
+++ b/src/mongo/db/auth/auth_index_d.cpp
@@ -28,6 +28,8 @@
#define MONGO_LOG_DEFAULT_COMPONENT ::mongo::logger::LogComponent::kAccessControl
+#include "mongo/platform/basic.h"
+
#include "mongo/db/auth/auth_index_d.h"
#include "mongo/base/init.h"
@@ -37,10 +39,10 @@
#include "mongo/db/catalog/collection.h"
#include "mongo/db/catalog/index_catalog.h"
#include "mongo/db/client.h"
+#include "mongo/db/client.h"
+#include "mongo/db/db_raii.h"
#include "mongo/db/index/index_descriptor.h"
#include "mongo/db/jsobj.h"
-#include "mongo/db/operation_context_impl.h"
-#include "mongo/db/db_raii.h"
#include "mongo/util/assert_util.h"
#include "mongo/util/log.h"
diff --git a/src/mongo/db/catalog/apply_ops.cpp b/src/mongo/db/catalog/apply_ops.cpp
index df7f90cb7b6..39a6ee25740 100644
--- a/src/mongo/db/catalog/apply_ops.cpp
+++ b/src/mongo/db/catalog/apply_ops.cpp
@@ -41,7 +41,6 @@
#include "mongo/db/matcher/extensions_callback_disallow_extensions.h"
#include "mongo/db/matcher/matcher.h"
#include "mongo/db/op_observer.h"
-#include "mongo/db/operation_context_impl.h"
#include "mongo/db/repl/oplog.h"
#include "mongo/db/repl/replication_coordinator_global.h"
#include "mongo/db/service_context.h"
diff --git a/src/mongo/db/catalog/capped_utils.cpp b/src/mongo/db/catalog/capped_utils.cpp
index 4b1e983ecd5..b11a17dd1cd 100644
--- a/src/mongo/db/catalog/capped_utils.cpp
+++ b/src/mongo/db/catalog/capped_utils.cpp
@@ -43,7 +43,6 @@
#include "mongo/db/curop.h"
#include "mongo/db/db_raii.h"
#include "mongo/db/index_builder.h"
-#include "mongo/db/operation_context_impl.h"
#include "mongo/db/query/internal_plans.h"
#include "mongo/db/query/plan_yield_policy.h"
#include "mongo/db/repl/replication_coordinator_global.h"
diff --git a/src/mongo/db/catalog/drop_collection.cpp b/src/mongo/db/catalog/drop_collection.cpp
index 857ba7252a9..32bc00edf90 100644
--- a/src/mongo/db/catalog/drop_collection.cpp
+++ b/src/mongo/db/catalog/drop_collection.cpp
@@ -41,7 +41,6 @@
#include "mongo/db/curop.h"
#include "mongo/db/db_raii.h"
#include "mongo/db/index_builder.h"
-#include "mongo/db/operation_context_impl.h"
#include "mongo/db/repl/replication_coordinator_global.h"
#include "mongo/db/server_options.h"
#include "mongo/db/service_context.h"
diff --git a/src/mongo/db/catalog/drop_database.cpp b/src/mongo/db/catalog/drop_database.cpp
index 5db42695d78..8b8a992ce5e 100644
--- a/src/mongo/db/catalog/drop_database.cpp
+++ b/src/mongo/db/catalog/drop_database.cpp
@@ -42,7 +42,6 @@
#include "mongo/db/db_raii.h"
#include "mongo/db/index_builder.h"
#include "mongo/db/op_observer.h"
-#include "mongo/db/operation_context_impl.h"
#include "mongo/db/repl/replication_coordinator_global.h"
#include "mongo/db/service_context.h"
#include "mongo/util/log.h"
diff --git a/src/mongo/db/clientcursor.cpp b/src/mongo/db/clientcursor.cpp
index 9dab496b5c4..52081f2976b 100644
--- a/src/mongo/db/clientcursor.cpp
+++ b/src/mongo/db/clientcursor.cpp
@@ -46,7 +46,6 @@
#include "mongo/db/commands/server_status.h"
#include "mongo/db/commands/server_status_metric.h"
#include "mongo/db/jsobj.h"
-#include "mongo/db/operation_context_impl.h"
#include "mongo/db/repl/repl_client_info.h"
#include "mongo/db/repl/replication_coordinator_global.h"
#include "mongo/db/server_parameters.h"
@@ -270,7 +269,8 @@ public:
const int Secs = 4;
while (!inShutdown()) {
{
- OperationContextImpl txn;
+ const ServiceContext::UniqueOperationContext txnPtr = cc().makeOperationContext();
+ OperationContext& txn = *txnPtr;
cursorStatsTimedOut.increment(
CursorManager::timeoutCursorsGlobal(&txn, t.millisReset()));
}
diff --git a/src/mongo/db/commands/clone_collection.cpp b/src/mongo/db/commands/clone_collection.cpp
index 85bd9c6b1ab..63d4b193605 100644
--- a/src/mongo/db/commands/clone_collection.cpp
+++ b/src/mongo/db/commands/clone_collection.cpp
@@ -50,7 +50,6 @@
#include "mongo/db/jsobj.h"
#include "mongo/db/namespace_string.h"
#include "mongo/db/repl/isself.h"
-#include "mongo/db/operation_context_impl.h"
#include "mongo/db/ops/insert.h"
#include "mongo/db/storage/storage_options.h"
#include "mongo/util/log.h"
diff --git a/src/mongo/db/commands/collection_to_capped.cpp b/src/mongo/db/commands/collection_to_capped.cpp
index 03d8552e2ae..59866778ab1 100644
--- a/src/mongo/db/commands/collection_to_capped.cpp
+++ b/src/mongo/db/commands/collection_to_capped.cpp
@@ -39,7 +39,6 @@
#include "mongo/db/service_context.h"
#include "mongo/db/index_builder.h"
#include "mongo/db/op_observer.h"
-#include "mongo/db/operation_context_impl.h"
#include "mongo/db/query/find.h"
#include "mongo/db/query/internal_plans.h"
#include "mongo/db/repl/replication_coordinator_global.h"
diff --git a/src/mongo/db/commands/compact.cpp b/src/mongo/db/commands/compact.cpp
index a87f2167be6..bc8061dfaa5 100644
--- a/src/mongo/db/commands/compact.cpp
+++ b/src/mongo/db/commands/compact.cpp
@@ -45,7 +45,6 @@
#include "mongo/db/db_raii.h"
#include "mongo/db/index_builder.h"
#include "mongo/db/jsobj.h"
-#include "mongo/db/operation_context_impl.h"
#include "mongo/db/repl/replication_coordinator_global.h"
#include "mongo/util/log.h"
diff --git a/src/mongo/db/commands/create_indexes.cpp b/src/mongo/db/commands/create_indexes.cpp
index 6032aa2c340..c5e67f6c833 100644
--- a/src/mongo/db/commands/create_indexes.cpp
+++ b/src/mongo/db/commands/create_indexes.cpp
@@ -41,7 +41,6 @@
#include "mongo/db/concurrency/write_conflict_exception.h"
#include "mongo/db/curop.h"
#include "mongo/db/service_context.h"
-#include "mongo/db/operation_context_impl.h"
#include "mongo/db/op_observer.h"
#include "mongo/db/ops/insert.h"
#include "mongo/db/repl/repl_client_info.h"
diff --git a/src/mongo/db/commands/drop_indexes.cpp b/src/mongo/db/commands/drop_indexes.cpp
index 950cf437750..7bd1c824102 100644
--- a/src/mongo/db/commands/drop_indexes.cpp
+++ b/src/mongo/db/commands/drop_indexes.cpp
@@ -53,7 +53,6 @@
#include "mongo/db/index/index_descriptor.h"
#include "mongo/db/index_builder.h"
#include "mongo/db/op_observer.h"
-#include "mongo/db/operation_context_impl.h"
#include "mongo/db/repl/replication_coordinator_global.h"
#include "mongo/util/log.h"
diff --git a/src/mongo/db/commands/fsync.cpp b/src/mongo/db/commands/fsync.cpp
index d8545f0853d..0cb5f32f83f 100644
--- a/src/mongo/db/commands/fsync.cpp
+++ b/src/mongo/db/commands/fsync.cpp
@@ -39,7 +39,6 @@
#include "mongo/bson/bsonobj.h"
#include "mongo/bson/bsonobjbuilder.h"
#include "mongo/db/audit.h"
-#include "mongo/db/db.h"
#include "mongo/db/auth/action_set.h"
#include "mongo/db/auth/action_type.h"
#include "mongo/db/auth/authorization_manager.h"
@@ -49,7 +48,7 @@
#include "mongo/db/commands.h"
#include "mongo/db/concurrency/d_concurrency.h"
#include "mongo/db/concurrency/write_conflict_exception.h"
-#include "mongo/db/operation_context_impl.h"
+#include "mongo/db/db.h"
#include "mongo/db/service_context.h"
#include "mongo/db/storage/mmap_v1/dur.h"
#include "mongo/db/storage/storage_engine.h"
@@ -233,7 +232,8 @@ SimpleMutex filesLockedFsync;
void FSyncLockThread::doRealWork() {
stdx::lock_guard<SimpleMutex> lkf(filesLockedFsync);
- OperationContextImpl txn;
+ const ServiceContext::UniqueOperationContext txnPtr = cc().makeOperationContext();
+ OperationContext& txn = *txnPtr;
ScopedTransaction transaction(&txn, MODE_X);
Lock::GlobalWrite global(txn.lockState()); // No WriteUnitOfWork needed
diff --git a/src/mongo/db/commands/mr.cpp b/src/mongo/db/commands/mr.cpp
index 9e5e6259d3e..0a3bd23ac88 100644
--- a/src/mongo/db/commands/mr.cpp
+++ b/src/mongo/db/commands/mr.cpp
@@ -41,6 +41,7 @@
#include "mongo/db/catalog/collection_catalog_entry.h"
#include "mongo/db/catalog/database_holder.h"
#include "mongo/db/catalog/document_validation.h"
+#include "mongo/db/client.h"
#include "mongo/db/clientcursor.h"
#include "mongo/db/commands.h"
#include "mongo/db/concurrency/write_conflict_exception.h"
@@ -48,24 +49,23 @@
#include "mongo/db/db_raii.h"
#include "mongo/db/dbhelpers.h"
#include "mongo/db/exec/working_set_common.h"
-#include "mongo/db/service_context.h"
#include "mongo/db/index/index_descriptor.h"
#include "mongo/db/instance.h"
-#include "mongo/db/matcher/matcher.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/operation_context_impl.h"
#include "mongo/db/ops/insert.h"
+#include "mongo/db/query/find_common.h"
#include "mongo/db/query/get_executor.h"
#include "mongo/db/query/query_planner.h"
-#include "mongo/db/query/find_common.h"
#include "mongo/db/range_preserver.h"
#include "mongo/db/repl/replication_coordinator_global.h"
#include "mongo/db/s/collection_metadata.h"
#include "mongo/db/s/operation_sharding_state.h"
#include "mongo/db/s/sharded_connection_info.h"
#include "mongo/db/s/sharding_state.h"
+#include "mongo/db/service_context.h"
#include "mongo/s/catalog/catalog_cache.h"
#include "mongo/s/chunk_manager.h"
#include "mongo/s/client/shard_registry.h"
diff --git a/src/mongo/db/commands/rename_collection_cmd.cpp b/src/mongo/db/commands/rename_collection_cmd.cpp
index eb42664c57b..8b764169ad9 100644
--- a/src/mongo/db/commands/rename_collection_cmd.cpp
+++ b/src/mongo/db/commands/rename_collection_cmd.cpp
@@ -45,7 +45,6 @@
#include "mongo/db/index_builder.h"
#include "mongo/db/namespace_string.h"
#include "mongo/db/op_observer.h"
-#include "mongo/db/operation_context_impl.h"
#include "mongo/db/ops/insert.h"
#include "mongo/db/repl/replication_coordinator_global.h"
#include "mongo/util/scopeguard.h"
diff --git a/src/mongo/db/commands/test_commands.cpp b/src/mongo/db/commands/test_commands.cpp
index 58d554cef84..f7fc056a931 100644
--- a/src/mongo/db/commands/test_commands.cpp
+++ b/src/mongo/db/commands/test_commands.cpp
@@ -44,7 +44,6 @@
#include "mongo/db/service_context.h"
#include "mongo/db/index_builder.h"
#include "mongo/db/op_observer.h"
-#include "mongo/db/operation_context_impl.h"
#include "mongo/db/query/internal_plans.h"
#include "mongo/db/repl/replication_coordinator_global.h"
#include "mongo/util/log.h"
diff --git a/src/mongo/db/commands/touch.cpp b/src/mongo/db/commands/touch.cpp
index 520f74e64a1..0ad5056ccad 100644
--- a/src/mongo/db/commands/touch.cpp
+++ b/src/mongo/db/commands/touch.cpp
@@ -46,7 +46,6 @@
#include "mongo/db/concurrency/d_concurrency.h"
#include "mongo/db/db_raii.h"
#include "mongo/db/jsobj.h"
-#include "mongo/db/operation_context_impl.h"
#include "mongo/util/timer.h"
#include "mongo/util/touch_pages.h"
diff --git a/src/mongo/db/commands/validate.cpp b/src/mongo/db/commands/validate.cpp
index 12e9cb7209a..0037eba6d58 100644
--- a/src/mongo/db/commands/validate.cpp
+++ b/src/mongo/db/commands/validate.cpp
@@ -33,9 +33,9 @@
#include "mongo/platform/basic.h"
#include "mongo/db/catalog/collection.h"
+#include "mongo/db/client.h"
#include "mongo/db/commands.h"
#include "mongo/db/db_raii.h"
-#include "mongo/db/operation_context_impl.h"
#include "mongo/db/query/internal_plans.h"
#include "mongo/util/fail_point_service.h"
#include "mongo/util/log.h"
diff --git a/src/mongo/db/index_builder.cpp b/src/mongo/db/index_builder.cpp
index b347c5de7d2..d1ff24fdecb 100644
--- a/src/mongo/db/index_builder.cpp
+++ b/src/mongo/db/index_builder.cpp
@@ -40,7 +40,6 @@
#include "mongo/db/concurrency/write_conflict_exception.h"
#include "mongo/db/curop.h"
#include "mongo/db/db_raii.h"
-#include "mongo/db/operation_context_impl.h"
#include "mongo/util/assert_util.h"
#include "mongo/util/log.h"
#include "mongo/util/mongoutils/str.h"
@@ -82,7 +81,8 @@ void IndexBuilder::run() {
Client::initThread(name().c_str());
LOG(2) << "IndexBuilder building index " << _index;
- OperationContextImpl txn;
+ const ServiceContext::UniqueOperationContext txnPtr = cc().makeOperationContext();
+ OperationContext& txn = *txnPtr;
txn.lockState()->setIsBatchWriter(true);
AuthorizationSession::get(txn.getClient())->grantInternalAuthorization();
diff --git a/src/mongo/db/index_rebuilder.cpp b/src/mongo/db/index_rebuilder.cpp
index d416d9fe087..cbc90157404 100644
--- a/src/mongo/db/index_rebuilder.cpp
+++ b/src/mongo/db/index_rebuilder.cpp
@@ -45,7 +45,6 @@
#include "mongo/db/db_raii.h"
#include "mongo/db/service_context.h"
#include "mongo/db/instance.h"
-#include "mongo/db/operation_context_impl.h"
#include "mongo/db/storage/storage_engine.h"
#include "mongo/util/log.h"
#include "mongo/util/scopeguard.h"
diff --git a/src/mongo/db/instance.cpp b/src/mongo/db/instance.cpp
index d3cac033950..947f0485c2c 100644
--- a/src/mongo/db/instance.cpp
+++ b/src/mongo/db/instance.cpp
@@ -42,6 +42,7 @@
#include "mongo/db/auth/authz_manager_external_state_d.h"
#include "mongo/db/background.h"
#include "mongo/db/catalog/index_create.h"
+#include "mongo/db/client.h"
#include "mongo/db/clientcursor.h"
#include "mongo/db/commands.h"
#include "mongo/db/commands/fsync.h"
@@ -66,7 +67,6 @@
#include "mongo/db/mongod_options.h"
#include "mongo/db/namespace_string.h"
#include "mongo/db/op_observer.h"
-#include "mongo/db/operation_context_impl.h"
#include "mongo/db/ops/delete_request.h"
#include "mongo/db/ops/insert.h"
#include "mongo/db/ops/parsed_delete.h"
diff --git a/src/mongo/db/operation_context_impl.h b/src/mongo/db/operation_context_impl.h
index b24772d1313..e3474939d7b 100644
--- a/src/mongo/db/operation_context_impl.h
+++ b/src/mongo/db/operation_context_impl.h
@@ -35,8 +35,6 @@ namespace mongo {
class OperationContextImpl : public OperationContext {
public:
- OperationContextImpl();
-
virtual ~OperationContextImpl();
virtual RecoveryUnit* recoveryUnit() const override;
@@ -63,6 +61,10 @@ public:
virtual bool writesAreReplicated() const override;
private:
+ friend class ServiceContextMongoD;
+
+ OperationContextImpl();
+
std::unique_ptr<RecoveryUnit> _recovery;
bool _writesAreReplicated;
};
diff --git a/src/mongo/db/ops/update.cpp b/src/mongo/db/ops/update.cpp
index df64f72b232..94caffaed71 100644
--- a/src/mongo/db/ops/update.cpp
+++ b/src/mongo/db/ops/update.cpp
@@ -38,11 +38,11 @@
#include "mongo/db/catalog/collection.h"
#include "mongo/db/catalog/database.h"
#include "mongo/db/catalog/database_holder.h"
+#include "mongo/db/client.h"
#include "mongo/db/clientcursor.h"
#include "mongo/db/concurrency/d_concurrency.h"
#include "mongo/db/concurrency/write_conflict_exception.h"
#include "mongo/db/exec/update.h"
-#include "mongo/db/operation_context_impl.h"
#include "mongo/db/op_observer.h"
#include "mongo/db/ops/update_driver.h"
#include "mongo/db/ops/update_lifecycle.h"
diff --git a/src/mongo/db/repl/bgsync.cpp b/src/mongo/db/repl/bgsync.cpp
index 4e1b724d767..cd25fbe664f 100644
--- a/src/mongo/db/repl/bgsync.cpp
+++ b/src/mongo/db/repl/bgsync.cpp
@@ -42,7 +42,6 @@
#include "mongo/db/commands/server_status_metric.h"
#include "mongo/db/concurrency/write_conflict_exception.h"
#include "mongo/db/dbhelpers.h"
-#include "mongo/db/operation_context_impl.h"
#include "mongo/db/repl/oplog.h"
#include "mongo/db/repl/oplog_interface_local.h"
#include "mongo/db/repl/replication_coordinator_global.h"
@@ -248,7 +247,8 @@ void BackgroundSync::_producerThread() {
}
// we want to start when we're no longer primary
// start() also loads _lastOpTimeFetched, which we know is set from the "if"
- OperationContextImpl txn;
+ const ServiceContext::UniqueOperationContext txnPtr = cc().makeOperationContext();
+ OperationContext& txn = *txnPtr;
if (isStopped()) {
start(&txn);
}
diff --git a/src/mongo/db/repl/initial_sync.cpp b/src/mongo/db/repl/initial_sync.cpp
index 09553e3d93e..c1e9c9269ce 100644
--- a/src/mongo/db/repl/initial_sync.cpp
+++ b/src/mongo/db/repl/initial_sync.cpp
@@ -32,17 +32,15 @@
#include "mongo/db/repl/initial_sync.h"
-#include "mongo/db/operation_context_impl.h"
+#include "mongo/db/client.h"
#include "mongo/db/repl/bgsync.h"
#include "mongo/db/repl/oplog.h"
#include "mongo/db/repl/optime.h"
-#include "mongo/db/repl/replication_coordinator_global.h"
#include "mongo/db/repl/repl_client_info.h"
-
+#include "mongo/db/repl/replication_coordinator_global.h"
#include "mongo/util/exit.h"
#include "mongo/util/log.h"
-
namespace mongo {
namespace repl {
diff --git a/src/mongo/db/repl/master_slave.cpp b/src/mongo/db/repl/master_slave.cpp
index e716cf58b3e..4aa6ed40159 100644
--- a/src/mongo/db/repl/master_slave.cpp
+++ b/src/mongo/db/repl/master_slave.cpp
@@ -51,13 +51,13 @@
#include "mongo/db/catalog/database_catalog_entry.h"
#include "mongo/db/catalog/database_holder.h"
#include "mongo/db/catalog/document_validation.h"
+#include "mongo/db/client.h"
#include "mongo/db/cloner.h"
#include "mongo/db/commands.h"
#include "mongo/db/db_raii.h"
#include "mongo/db/dbdirectclient.h"
#include "mongo/db/dbhelpers.h"
#include "mongo/db/op_observer.h"
-#include "mongo/db/operation_context_impl.h"
#include "mongo/db/ops/update.h"
#include "mongo/db/query/internal_plans.h"
#include "mongo/db/repl/handshake_args.h"
@@ -1274,7 +1274,8 @@ static void replMasterThread() {
// Write a keep-alive like entry to the log. This will make things like
// printReplicationStatus() and printSlaveReplicationStatus() stay up-to-date even
// when things are idle.
- OperationContextImpl txn;
+ const ServiceContext::UniqueOperationContext txnPtr = cc().makeOperationContext();
+ OperationContext& txn = *txnPtr;
AuthorizationSession::get(txn.getClient())->grantInternalAuthorization();
Lock::GlobalWrite globalWrite(txn.lockState(), 1);
@@ -1299,7 +1300,8 @@ static void replSlaveThread() {
sleepsecs(1);
Client::initThread("replslave");
- OperationContextImpl txn;
+ const ServiceContext::UniqueOperationContext txnPtr = cc().makeOperationContext();
+ OperationContext& txn = *txnPtr;
AuthorizationSession::get(txn.getClient())->grantInternalAuthorization();
DisableDocumentValidation validationDisabler(&txn);
@@ -1356,7 +1358,8 @@ int _dummy_z;
void pretouchN(vector<BSONObj>& v, unsigned a, unsigned b) {
Client::initThreadIfNotAlready("pretouchN");
- OperationContextImpl txn; // XXX
+ const ServiceContext::UniqueOperationContext txnPtr = cc().makeOperationContext();
+ OperationContext& txn = *txnPtr; // XXX
ScopedTransaction transaction(&txn, MODE_S);
Lock::GlobalRead lk(txn.lockState());
diff --git a/src/mongo/db/repl/oplog.cpp b/src/mongo/db/repl/oplog.cpp
index e0a7aa19737..5acc636c0cb 100644
--- a/src/mongo/db/repl/oplog.cpp
+++ b/src/mongo/db/repl/oplog.cpp
@@ -41,20 +41,21 @@
#include "mongo/bson/util/bson_extract.h"
#include "mongo/db/auth/action_set.h"
#include "mongo/db/auth/action_type.h"
-#include "mongo/db/auth/authorization_manager_global.h"
#include "mongo/db/auth/authorization_manager.h"
+#include "mongo/db/auth/authorization_manager_global.h"
#include "mongo/db/auth/privilege.h"
#include "mongo/db/background.h"
#include "mongo/db/catalog/apply_ops.h"
#include "mongo/db/catalog/capped_utils.h"
#include "mongo/db/catalog/coll_mod.h"
-#include "mongo/db/catalog/collection_catalog_entry.h"
#include "mongo/db/catalog/collection.h"
+#include "mongo/db/catalog/collection_catalog_entry.h"
#include "mongo/db/catalog/create_collection.h"
#include "mongo/db/catalog/drop_collection.h"
#include "mongo/db/catalog/drop_database.h"
#include "mongo/db/catalog/drop_indexes.h"
#include "mongo/db/catalog/rename_collection.h"
+#include "mongo/db/client.h"
#include "mongo/db/commands.h"
#include "mongo/db/commands/dbhash.h"
#include "mongo/db/concurrency/write_conflict_exception.h"
@@ -62,15 +63,14 @@
#include "mongo/db/dbdirectclient.h"
#include "mongo/db/dbhelpers.h"
#include "mongo/db/global_timestamp.h"
-#include "mongo/db/index_builder.h"
#include "mongo/db/index/index_access_method.h"
+#include "mongo/db/index_builder.h"
#include "mongo/db/keypattern.h"
#include "mongo/db/namespace_string.h"
#include "mongo/db/op_observer.h"
-#include "mongo/db/operation_context_impl.h"
#include "mongo/db/ops/delete.h"
-#include "mongo/db/ops/update_lifecycle_impl.h"
#include "mongo/db/ops/update.h"
+#include "mongo/db/ops/update_lifecycle_impl.h"
#include "mongo/db/repl/bgsync.h"
#include "mongo/db/repl/oplogreader.h"
#include "mongo/db/repl/optime.h"
@@ -81,8 +81,8 @@
#include "mongo/db/server_parameters.h"
#include "mongo/db/service_context.h"
#include "mongo/db/stats/counters.h"
-#include "mongo/db/storage/storage_options.h"
#include "mongo/db/storage/storage_engine.h"
+#include "mongo/db/storage/storage_options.h"
#include "mongo/platform/random.h"
#include "mongo/scripting/engine.h"
#include "mongo/stdx/memory.h"
diff --git a/src/mongo/db/repl/replication_coordinator_external_state_impl.cpp b/src/mongo/db/repl/replication_coordinator_external_state_impl.cpp
index c7ef3033c83..79eea7fcc31 100644
--- a/src/mongo/db/repl/replication_coordinator_external_state_impl.cpp
+++ b/src/mongo/db/repl/replication_coordinator_external_state_impl.cpp
@@ -45,7 +45,6 @@
#include "mongo/db/dbhelpers.h"
#include "mongo/db/jsobj.h"
#include "mongo/db/op_observer.h"
-#include "mongo/db/operation_context_impl.h"
#include "mongo/db/repl/bgsync.h"
#include "mongo/db/repl/isself.h"
#include "mongo/db/repl/last_vote.h"
diff --git a/src/mongo/db/repl/replication_info.cpp b/src/mongo/db/repl/replication_info.cpp
index 9852803a3b3..6c450ce34ba 100644
--- a/src/mongo/db/repl/replication_info.cpp
+++ b/src/mongo/db/repl/replication_info.cpp
@@ -32,13 +32,13 @@
#include <vector>
#include "mongo/client/connpool.h"
+#include "mongo/db/client.h"
#include "mongo/db/commands/server_status.h"
#include "mongo/db/db_raii.h"
#include "mongo/db/dbhelpers.h"
#include "mongo/db/exec/working_set_common.h"
#include "mongo/db/jsobj.h"
#include "mongo/db/lasterror.h"
-#include "mongo/db/operation_context_impl.h"
#include "mongo/db/query/internal_plans.h"
#include "mongo/db/repl/is_master_response.h"
#include "mongo/db/repl/master_slave.h"
diff --git a/src/mongo/db/repl/rs_initialsync.cpp b/src/mongo/db/repl/rs_initialsync.cpp
index 88f99294755..cb4cd2826d5 100644
--- a/src/mongo/db/repl/rs_initialsync.cpp
+++ b/src/mongo/db/repl/rs_initialsync.cpp
@@ -45,8 +45,6 @@
#include "mongo/db/dbhelpers.h"
#include "mongo/db/service_context.h"
#include "mongo/db/op_observer.h"
-#include "mongo/db/operation_context_impl.h"
-#include "mongo/db/operation_context_impl.h"
#include "mongo/db/repl/bgsync.h"
#include "mongo/db/repl/initial_sync.h"
#include "mongo/db/repl/oplog.h"
@@ -311,7 +309,8 @@ Status _initialSync() {
log() << "initial sync pending";
BackgroundSync* bgsync(BackgroundSync::get());
- OperationContextImpl txn;
+ const ServiceContext::UniqueOperationContext txnPtr = cc().makeOperationContext();
+ OperationContext& txn = *txnPtr;
txn.setReplicatedWrites(false);
DisableDocumentValidation validationDisabler(&txn);
ReplicationCoordinator* replCoord(getGlobalReplicationCoordinator());
@@ -467,7 +466,8 @@ void syncDoInitialSync() {
}
{
- OperationContextImpl txn;
+ const ServiceContext::UniqueOperationContext txnPtr = cc().makeOperationContext();
+ OperationContext& txn = *txnPtr;
createOplog(&txn);
}
diff --git a/src/mongo/db/repl/rs_sync.cpp b/src/mongo/db/repl/rs_sync.cpp
index 82762d3733e..cc8eaa320e5 100644
--- a/src/mongo/db/repl/rs_sync.cpp
+++ b/src/mongo/db/repl/rs_sync.cpp
@@ -52,7 +52,6 @@
#include "mongo/db/repl/sync_tail.h"
#include "mongo/db/server_parameters.h"
#include "mongo/db/stats/timer_stats.h"
-#include "mongo/db/operation_context_impl.h"
#include "mongo/db/storage/storage_options.h"
#include "mongo/util/exit.h"
#include "mongo/util/fail_point_service.h"
diff --git a/src/mongo/db/repl/storage_interface_impl.cpp b/src/mongo/db/repl/storage_interface_impl.cpp
index 23f9d4ce0b7..ef9935ae86f 100644
--- a/src/mongo/db/repl/storage_interface_impl.cpp
+++ b/src/mongo/db/repl/storage_interface_impl.cpp
@@ -38,7 +38,7 @@
#include "mongo/db/curop.h"
#include "mongo/db/dbhelpers.h"
#include "mongo/db/jsobj.h"
-#include "mongo/db/operation_context_impl.h"
+#include "mongo/db/operation_context.h"
#include "mongo/db/repl/replication_coordinator.h"
#include "mongo/db/service_context.h"
#include "mongo/util/assert_util.h"
diff --git a/src/mongo/db/repl/sync_source_feedback.cpp b/src/mongo/db/repl/sync_source_feedback.cpp
index 43a9b077d83..136978df15b 100644
--- a/src/mongo/db/repl/sync_source_feedback.cpp
+++ b/src/mongo/db/repl/sync_source_feedback.cpp
@@ -33,7 +33,6 @@
#include "mongo/db/repl/sync_source_feedback.h"
#include "mongo/db/client.h"
-#include "mongo/db/operation_context_impl.h"
#include "mongo/db/repl/bgsync.h"
#include "mongo/db/repl/replica_set_config.h"
#include "mongo/db/repl/replication_coordinator.h"
diff --git a/src/mongo/db/repl/sync_tail.cpp b/src/mongo/db/repl/sync_tail.cpp
index e6e9e69cca0..0c8d5af2264 100644
--- a/src/mongo/db/repl/sync_tail.cpp
+++ b/src/mongo/db/repl/sync_tail.cpp
@@ -40,18 +40,18 @@
#include "mongo/base/counter.h"
#include "mongo/db/auth/authorization_session.h"
#include "mongo/db/catalog/collection.h"
-#include "mongo/db/catalog/database_holder.h"
#include "mongo/db/catalog/database.h"
+#include "mongo/db/catalog/database_holder.h"
#include "mongo/db/catalog/document_validation.h"
+#include "mongo/db/client.h"
#include "mongo/db/commands/fsync.h"
#include "mongo/db/commands/server_status_metric.h"
#include "mongo/db/concurrency/d_concurrency.h"
#include "mongo/db/concurrency/write_conflict_exception.h"
-#include "mongo/db/dbhelpers.h"
#include "mongo/db/curop.h"
#include "mongo/db/db_raii.h"
+#include "mongo/db/dbhelpers.h"
#include "mongo/db/global_timestamp.h"
-#include "mongo/db/operation_context_impl.h"
#include "mongo/db/prefetch.h"
#include "mongo/db/query/query_knobs.h"
#include "mongo/db/repl/bgsync.h"
@@ -418,7 +418,8 @@ void prefetchOp(const BSONObj& op) {
try {
// one possible tweak here would be to stay in the read lock for this database
// for multiple prefetches if they are for the same database.
- OperationContextImpl txn;
+ const ServiceContext::UniqueOperationContext txnPtr = cc().makeOperationContext();
+ OperationContext& txn = *txnPtr;
AutoGetCollectionForRead ctx(&txn, ns);
Database* db = ctx.getDb();
if (db) {
@@ -611,7 +612,8 @@ public:
private:
void run() {
Client::initThread("ReplBatcher");
- OperationContextImpl txn;
+ const ServiceContext::UniqueOperationContext txnPtr = cc().makeOperationContext();
+ OperationContext& txn = *txnPtr;
auto replCoord = ReplicationCoordinator::get(&txn);
while (!_inShutdown.load()) {
@@ -683,7 +685,8 @@ private:
void SyncTail::oplogApplication() {
OpQueueBatcher batcher(this);
- OperationContextImpl txn;
+ const ServiceContext::UniqueOperationContext txnPtr = cc().makeOperationContext();
+ OperationContext& txn = *txnPtr;
auto replCoord = ReplicationCoordinator::get(&txn);
std::unique_ptr<ApplyBatchFinalizer> finalizer{
getGlobalServiceContext()->getGlobalStorageEngine()->isDurable()
@@ -983,7 +986,8 @@ void multiSyncApply(const std::vector<OplogEntry>& ops) {
}
initializeWriterThread();
- OperationContextImpl txn;
+ const ServiceContext::UniqueOperationContext txnPtr = cc().makeOperationContext();
+ OperationContext& txn = *txnPtr;
txn.setReplicatedWrites(false);
DisableDocumentValidation validationDisabler(&txn);
@@ -1089,7 +1093,8 @@ void multiSyncApply(const std::vector<OplogEntry>& ops) {
void multiInitialSyncApply(const std::vector<OplogEntry>& ops) {
initializeWriterThread();
- OperationContextImpl txn;
+ const ServiceContext::UniqueOperationContext txnPtr = cc().makeOperationContext();
+ OperationContext& txn = *txnPtr;
txn.setReplicatedWrites(false);
DisableDocumentValidation validationDisabler(&txn);
diff --git a/src/mongo/db/service_context_d.cpp b/src/mongo/db/service_context_d.cpp
index ea05ccacaf6..ecb449e7adb 100644
--- a/src/mongo/db/service_context_d.cpp
+++ b/src/mongo/db/service_context_d.cpp
@@ -320,7 +320,7 @@ void ServiceContextMongoD::registerKillOpListener(KillOpListenerInterface* liste
std::unique_ptr<OperationContext> ServiceContextMongoD::_newOpCtx(Client* client) {
invariant(&cc() == client);
- return stdx::make_unique<OperationContextImpl>();
+ return std::unique_ptr<OperationContextImpl>(new OperationContextImpl());
}
void ServiceContextMongoD::setOpObserver(std::unique_ptr<OpObserver> opObserver) {
diff --git a/src/mongo/db/service_context_d_test_fixture.cpp b/src/mongo/db/service_context_d_test_fixture.cpp
index b281cc8994e..a588a708ca5 100644
--- a/src/mongo/db/service_context_d_test_fixture.cpp
+++ b/src/mongo/db/service_context_d_test_fixture.cpp
@@ -32,13 +32,13 @@
#include "mongo/base/checked_cast.h"
#include "mongo/db/catalog/database.h"
+#include "mongo/db/client.h"
#include "mongo/db/concurrency/write_conflict_exception.h"
#include "mongo/db/curop.h"
#include "mongo/db/db_raii.h"
-#include "mongo/db/operation_context_impl.h"
#include "mongo/db/operation_context.h"
-#include "mongo/db/service_context_d.h"
#include "mongo/db/service_context.h"
+#include "mongo/db/service_context_d.h"
#include "mongo/db/storage/storage_options.h"
#include "mongo/unittest/temp_dir.h"
@@ -63,19 +63,19 @@ void ServiceContextMongoDTest::tearDown() {
}
void ServiceContextMongoDTest::_dropAllDBs() {
- OperationContextImpl txn;
- dropAllDatabasesExceptLocal(&txn);
+ const auto txn = cc().makeOperationContext();
+ dropAllDatabasesExceptLocal(txn.get());
- ScopedTransaction transaction(&txn, MODE_X);
- Lock::GlobalWrite lk(txn.lockState());
- AutoGetDb autoDBLocal(&txn, "local", MODE_X);
+ ScopedTransaction transaction(txn.get(), MODE_X);
+ Lock::GlobalWrite lk(txn->lockState());
+ AutoGetDb autoDBLocal(txn.get(), "local", MODE_X);
const auto localDB = autoDBLocal.getDb();
if (localDB) {
MONGO_WRITE_CONFLICT_RETRY_LOOP_BEGIN {
// Do not wrap in a WriteUnitOfWork until SERVER-17103 is addressed.
- autoDBLocal.getDb()->dropDatabase(&txn, localDB);
+ autoDBLocal.getDb()->dropDatabase(txn.get(), localDB);
}
- MONGO_WRITE_CONFLICT_RETRY_LOOP_END(&txn, "_dropAllDBs", "local");
+ MONGO_WRITE_CONFLICT_RETRY_LOOP_END(txn.get(), "_dropAllDBs", "local");
}
}
diff --git a/src/mongo/db/storage/mmap_v1/dur.cpp b/src/mongo/db/storage/mmap_v1/dur.cpp
index f50be1ce146..fee1652b440 100644
--- a/src/mongo/db/storage/mmap_v1/dur.cpp
+++ b/src/mongo/db/storage/mmap_v1/dur.cpp
@@ -81,7 +81,6 @@
#include "mongo/db/client.h"
#include "mongo/db/commands/server_status.h"
#include "mongo/db/concurrency/lock_state.h"
-#include "mongo/db/operation_context_impl.h"
#include "mongo/db/storage/mmap_v1/aligned_builder.h"
#include "mongo/db/storage/mmap_v1/dur_commitjob.h"
#include "mongo/db/storage/mmap_v1/dur_journal.h"
@@ -716,7 +715,8 @@ static void durThread() {
Timer t;
- OperationContextImpl txn;
+ const ServiceContext::UniqueOperationContext txnPtr = cc().makeOperationContext();
+ OperationContext& txn = *txnPtr;
AutoAcquireFlushLockForMMAPV1Commit autoFlushLock(txn.lockState());
// We need to snapshot the commitNumber after the flush lock has been obtained,
diff --git a/src/mongo/db/storage/mmap_v1/dur_recover.cpp b/src/mongo/db/storage/mmap_v1/dur_recover.cpp
index 72c37788b37..69e700bc187 100644
--- a/src/mongo/db/storage/mmap_v1/dur_recover.cpp
+++ b/src/mongo/db/storage/mmap_v1/dur_recover.cpp
@@ -40,7 +40,8 @@
#include <iostream>
#include <sys/stat.h>
-#include "mongo/db/operation_context_impl.h"
+#include "mongo/db/client.h"
+#include "mongo/db/operation_context.h"
#include "mongo/db/storage/mmap_v1/compress.h"
#include "mongo/db/storage/mmap_v1/dur_commitjob.h"
#include "mongo/db/storage/mmap_v1/dur_journal.h"
@@ -628,7 +629,8 @@ void _recover() {
void replayJournalFilesAtStartup() {
// we use a lock so that exitCleanly will wait for us
// to finish (or at least to notice what is up and stop)
- OperationContextImpl txn;
+ const ServiceContext::UniqueOperationContext txnPtr = cc().makeOperationContext();
+ OperationContext& txn = *txnPtr;
ScopedTransaction transaction(&txn, MODE_X);
Lock::GlobalWrite lk(txn.lockState());
diff --git a/src/mongo/db/storage/mmap_v1/record_store_v1_capped.cpp b/src/mongo/db/storage/mmap_v1/record_store_v1_capped.cpp
index a21b7bab880..350a9fc1cdf 100644
--- a/src/mongo/db/storage/mmap_v1/record_store_v1_capped.cpp
+++ b/src/mongo/db/storage/mmap_v1/record_store_v1_capped.cpp
@@ -32,7 +32,7 @@
#include "mongo/db/storage/mmap_v1/record_store_v1_capped.h"
-#include "mongo/db/operation_context_impl.h"
+#include "mongo/db/client.h"
#include "mongo/db/storage/mmap_v1/extent.h"
#include "mongo/db/storage/mmap_v1/extent_manager.h"
#include "mongo/db/storage/mmap_v1/mmap.h"
diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_record_store_mongod.cpp b/src/mongo/db/storage/wiredtiger/wiredtiger_record_store_mongod.cpp
index ce089a38ce9..4d2bb460585 100644
--- a/src/mongo/db/storage/wiredtiger/wiredtiger_record_store_mongod.cpp
+++ b/src/mongo/db/storage/wiredtiger/wiredtiger_record_store_mongod.cpp
@@ -40,7 +40,6 @@
#include "mongo/db/concurrency/d_concurrency.h"
#include "mongo/db/db_raii.h"
#include "mongo/db/namespace_string.h"
-#include "mongo/db/operation_context_impl.h"
#include "mongo/db/service_context.h"
#include "mongo/db/storage/wiredtiger/wiredtiger_kv_engine.h"
#include "mongo/db/storage/wiredtiger/wiredtiger_record_store.h"
@@ -77,7 +76,8 @@ public:
return false;
}
- OperationContextImpl txn;
+ const ServiceContext::UniqueOperationContext txnPtr = cc().makeOperationContext();
+ OperationContext& txn = *txnPtr;
try {
ScopedTransaction transaction(&txn, MODE_IX);
diff --git a/src/mongo/db/ttl.cpp b/src/mongo/db/ttl.cpp
index 9ee42d649a6..108c86d4e0f 100644
--- a/src/mongo/db/ttl.cpp
+++ b/src/mongo/db/ttl.cpp
@@ -48,7 +48,6 @@
#include "mongo/db/db_raii.h"
#include "mongo/db/exec/delete.h"
#include "mongo/db/index/index_descriptor.h"
-#include "mongo/db/operation_context_impl.h"
#include "mongo/db/ops/insert.h"
#include "mongo/db/matcher/extensions_callback_disallow_extensions.h"
#include "mongo/db/namespace_string.h"
@@ -121,7 +120,8 @@ public:
private:
void doTTLPass() {
// Count it as active from the moment the TTL thread wakes up
- OperationContextImpl txn;
+ const ServiceContext::UniqueOperationContext txnPtr = cc().makeOperationContext();
+ OperationContext& txn = *txnPtr;
// if part of replSet but not in a readable state (e.g. during initial sync), skip.
if (repl::getGlobalReplicationCoordinator()->getReplicationMode() ==