diff options
author | Andy Schwerin <schwerin@mongodb.com> | 2016-04-16 12:24:16 -0400 |
---|---|---|
committer | Andy Schwerin <schwerin@mongodb.com> | 2016-04-18 23:44:56 -0400 |
commit | 0ab34aa7b9c3c48ea6cf17888620fca455284d35 (patch) | |
tree | 9d592c0427229b53bdea159617f7de5d3c6ff819 /src | |
parent | bdc06761206ac398af04f0a2eb482c4dca49bad8 (diff) | |
download | mongo-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')
89 files changed, 373 insertions, 241 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() == diff --git a/src/mongo/dbtests/basictests.cpp b/src/mongo/dbtests/basictests.cpp index 613eef57475..a0b915027fa 100644 --- a/src/mongo/dbtests/basictests.cpp +++ b/src/mongo/dbtests/basictests.cpp @@ -33,7 +33,7 @@ #include <iostream> -#include "mongo/db/operation_context_impl.h" +#include "mongo/db/client.h" #include "mongo/db/storage/paths.h" #include "mongo/db/storage/mmap_v1/compress.h" #include "mongo/dbtests/dbtests.h" diff --git a/src/mongo/dbtests/clienttests.cpp b/src/mongo/dbtests/clienttests.cpp index 789a995e0eb..7764f5697c1 100644 --- a/src/mongo/dbtests/clienttests.cpp +++ b/src/mongo/dbtests/clienttests.cpp @@ -28,12 +28,14 @@ * then also delete it in the license file. */ +#include "mongo/platform/basic.h" + #include "mongo/client/dbclientcursor.h" #include "mongo/db/catalog/collection.h" #include "mongo/db/catalog/database.h" +#include "mongo/db/client.h" #include "mongo/db/db_raii.h" #include "mongo/db/dbdirectclient.h" -#include "mongo/db/operation_context_impl.h" #include "mongo/dbtests/dbtests.h" namespace ClientTests { @@ -45,14 +47,16 @@ using std::vector; class Base { public: Base(string coll) : _ns("test." + coll) { - OperationContextImpl txn; + const ServiceContext::UniqueOperationContext txnPtr = cc().makeOperationContext(); + OperationContext& txn = *txnPtr; DBDirectClient db(&txn); db.dropDatabase("test"); } virtual ~Base() { - OperationContextImpl txn; + const ServiceContext::UniqueOperationContext txnPtr = cc().makeOperationContext(); + OperationContext& txn = *txnPtr; DBDirectClient db(&txn); db.dropCollection(_ns); @@ -70,7 +74,8 @@ class DropIndex : public Base { public: DropIndex() : Base("dropindex") {} void run() { - OperationContextImpl txn; + const ServiceContext::UniqueOperationContext txnPtr = cc().makeOperationContext(); + OperationContext& txn = *txnPtr; DBDirectClient db(&txn); db.insert(ns(), BSON("x" << 2)); @@ -99,7 +104,8 @@ class BuildIndex : public Base { public: BuildIndex() : Base("buildIndex") {} void run() { - OperationContextImpl txn; + const ServiceContext::UniqueOperationContext txnPtr = cc().makeOperationContext(); + OperationContext& txn = *txnPtr; OldClientWriteContext ctx(&txn, ns()); DBDirectClient db(&txn); @@ -132,7 +138,8 @@ class CS_10 : public Base { public: CS_10() : Base("CS_10") {} void run() { - OperationContextImpl txn; + const ServiceContext::UniqueOperationContext txnPtr = cc().makeOperationContext(); + OperationContext& txn = *txnPtr; DBDirectClient db(&txn); const string longs(770, 'c'); @@ -151,7 +158,8 @@ class PushBack : public Base { public: PushBack() : Base("PushBack") {} void run() { - OperationContextImpl txn; + const ServiceContext::UniqueOperationContext txnPtr = cc().makeOperationContext(); + OperationContext& txn = *txnPtr; DBDirectClient db(&txn); for (int i = 0; i < 10; ++i) { @@ -196,7 +204,8 @@ class Create : public Base { public: Create() : Base("Create") {} void run() { - OperationContextImpl txn; + const ServiceContext::UniqueOperationContext txnPtr = cc().makeOperationContext(); + OperationContext& txn = *txnPtr; DBDirectClient db(&txn); db.createCollection("unittests.clienttests.create", 4096, true); diff --git a/src/mongo/dbtests/commandtests.cpp b/src/mongo/dbtests/commandtests.cpp index c09fd1a3de1..7bde7892429 100644 --- a/src/mongo/dbtests/commandtests.cpp +++ b/src/mongo/dbtests/commandtests.cpp @@ -28,9 +28,10 @@ #include "mongo/platform/basic.h" +#include "mongo/db/client.h" #include "mongo/db/concurrency/d_concurrency.h" #include "mongo/db/dbdirectclient.h" -#include "mongo/db/operation_context_impl.h" +#include "mongo/db/operation_context.h" #include "mongo/dbtests/dbtests.h" using namespace mongo; @@ -51,7 +52,8 @@ struct Base { return "test.fs.chunks"; } - OperationContextImpl _txn; + const ServiceContext::UniqueOperationContext _txnPtr = cc().makeOperationContext(); + OperationContext& _txn = *_txnPtr; DBDirectClient db; }; struct Type0 : Base { @@ -126,7 +128,8 @@ public: return "symbolarg"; } - OperationContextImpl _txn; + const ServiceContext::UniqueOperationContext _txnPtr = cc().makeOperationContext(); + OperationContext& _txn = *_txnPtr; DBDirectClient db; }; diff --git a/src/mongo/dbtests/counttests.cpp b/src/mongo/dbtests/counttests.cpp index 855113d66ec..f6f0f48c858 100644 --- a/src/mongo/dbtests/counttests.cpp +++ b/src/mongo/dbtests/counttests.cpp @@ -28,13 +28,15 @@ * then also delete it in the license file. */ +#include "mongo/platform/basic.h" + #include "mongo/db/catalog/collection.h" +#include "mongo/db/client.h" #include "mongo/db/db.h" #include "mongo/db/db_raii.h" #include "mongo/db/dbdirectclient.h" #include "mongo/db/dbhelpers.h" #include "mongo/db/json.h" -#include "mongo/db/operation_context_impl.h" #include "mongo/stdx/thread.h" #include "mongo/dbtests/dbtests.h" @@ -44,8 +46,7 @@ namespace CountTests { class Base { public: Base() - : _txn(), - _scopedXact(&_txn, MODE_IX), + : _scopedXact(&_txn, MODE_IX), _lk(_txn.lockState(), nsToDatabaseSubstring(ns()), MODE_X), _context(&_txn, ns()), _client(&_txn) { @@ -104,7 +105,8 @@ protected: } - OperationContextImpl _txn; + const ServiceContext::UniqueOperationContext _txnPtr = cc().makeOperationContext(); + OperationContext& _txn = *_txnPtr; ScopedTransaction _scopedXact; Lock::DBLock _lk; diff --git a/src/mongo/dbtests/dbhelper_tests.cpp b/src/mongo/dbtests/dbhelper_tests.cpp index 8d7909eac65..aee6a0f406a 100644 --- a/src/mongo/dbtests/dbhelper_tests.cpp +++ b/src/mongo/dbtests/dbhelper_tests.cpp @@ -31,10 +31,10 @@ #include "mongo/client/dbclientcursor.h" #include "mongo/db/catalog/collection.h" #include "mongo/db/catalog/database_holder.h" +#include "mongo/db/client.h" #include "mongo/db/db_raii.h" #include "mongo/db/dbdirectclient.h" #include "mongo/db/dbhelpers.h" -#include "mongo/db/operation_context_impl.h" #include "mongo/db/range_arithmetic.h" #include "mongo/db/write_concern_options.h" #include "mongo/dbtests/dbtests.h" @@ -58,7 +58,8 @@ public: RemoveRange() : _min(4), _max(8) {} void run() { - OperationContextImpl txn; + const ServiceContext::UniqueOperationContext txnPtr = cc().makeOperationContext(); + OperationContext& txn = *txnPtr; DBDirectClient client(&txn); for (int i = 0; i < 10; ++i) { diff --git a/src/mongo/dbtests/directclienttests.cpp b/src/mongo/dbtests/directclienttests.cpp index fd32e9b57d1..e420ac1f0ab 100644 --- a/src/mongo/dbtests/directclienttests.cpp +++ b/src/mongo/dbtests/directclienttests.cpp @@ -38,7 +38,6 @@ #include "mongo/db/dbdirectclient.h" #include "mongo/db/json.h" #include "mongo/db/lasterror.h" -#include "mongo/db/operation_context_impl.h" #include "mongo/dbtests/dbtests.h" #include "mongo/util/timer.h" @@ -62,7 +61,8 @@ const char* ns = "a.b"; class Capped : public ClientBase { public: virtual void run() { - OperationContextImpl txn; + const ServiceContext::UniqueOperationContext txnPtr = cc().makeOperationContext(); + OperationContext& txn = *txnPtr; DBDirectClient client(&txn); for (int pass = 0; pass < 3; pass++) { client.createCollection(ns, 1024 * 1024, true, 999); @@ -89,7 +89,8 @@ public: class InsertMany : ClientBase { public: virtual void run() { - OperationContextImpl txn; + const ServiceContext::UniqueOperationContext txnPtr = cc().makeOperationContext(); + OperationContext& txn = *txnPtr; DBDirectClient client(&txn); vector<BSONObj> objs; @@ -113,7 +114,8 @@ public: class BadNSCmd : ClientBase { public: virtual void run() { - OperationContextImpl txn; + const ServiceContext::UniqueOperationContext txnPtr = cc().makeOperationContext(); + OperationContext& txn = *txnPtr; DBDirectClient client(&txn); BSONObj result; @@ -126,7 +128,8 @@ public: class BadNSQuery : ClientBase { public: virtual void run() { - OperationContextImpl txn; + const ServiceContext::UniqueOperationContext txnPtr = cc().makeOperationContext(); + OperationContext& txn = *txnPtr; DBDirectClient client(&txn); unique_ptr<DBClientCursor> cursor = client.query("", Query(), 1); @@ -140,7 +143,8 @@ public: class BadNSGetMore : ClientBase { public: virtual void run() { - OperationContextImpl txn; + const ServiceContext::UniqueOperationContext txnPtr = cc().makeOperationContext(); + OperationContext& txn = *txnPtr; DBDirectClient client(&txn); unique_ptr<DBClientCursor> cursor = client.getMore("", 1, 1); @@ -154,7 +158,8 @@ public: class BadNSInsert : ClientBase { public: virtual void run() { - OperationContextImpl txn; + const ServiceContext::UniqueOperationContext txnPtr = cc().makeOperationContext(); + OperationContext& txn = *txnPtr; DBDirectClient client(&txn); client.insert("", BSONObj(), 0); @@ -165,7 +170,8 @@ public: class BadNSUpdate : ClientBase { public: virtual void run() { - OperationContextImpl txn; + const ServiceContext::UniqueOperationContext txnPtr = cc().makeOperationContext(); + OperationContext& txn = *txnPtr; DBDirectClient client(&txn); client.update("", Query(), BSON("$set" << BSON("x" << 1))); @@ -176,7 +182,8 @@ public: class BadNSRemove : ClientBase { public: virtual void run() { - OperationContextImpl txn; + const ServiceContext::UniqueOperationContext txnPtr = cc().makeOperationContext(); + OperationContext& txn = *txnPtr; DBDirectClient client(&txn); client.remove("", Query()); diff --git a/src/mongo/dbtests/documentsourcetests.cpp b/src/mongo/dbtests/documentsourcetests.cpp index 27e2e2dc93b..4a777296e2b 100644 --- a/src/mongo/dbtests/documentsourcetests.cpp +++ b/src/mongo/dbtests/documentsourcetests.cpp @@ -30,16 +30,17 @@ #include "mongo/platform/basic.h" +#include "mongo/db/client.h" #include "mongo/db/db_raii.h" #include "mongo/db/dbdirectclient.h" #include "mongo/db/matcher/extensions_callback_disallow_extensions.h" -#include "mongo/db/operation_context_impl.h" #include "mongo/db/pipeline/dependencies.h" #include "mongo/db/pipeline/document_source.h" #include "mongo/db/pipeline/expression_context.h" #include "mongo/db/pipeline/pipeline.h" #include "mongo/db/query/get_executor.h" #include "mongo/dbtests/dbtests.h" + namespace DocumentSourceCursorTests { using boost::intrusive_ptr; @@ -66,7 +67,8 @@ public: } protected: - OperationContextImpl _opCtx; + const ServiceContext::UniqueOperationContext _opCtxPtr = cc().makeOperationContext(); + OperationContext& _opCtx = *_opCtxPtr; DBDirectClient client; }; diff --git a/src/mongo/dbtests/executor_registry.cpp b/src/mongo/dbtests/executor_registry.cpp index 46735b627b5..564ddcc7da6 100644 --- a/src/mongo/dbtests/executor_registry.cpp +++ b/src/mongo/dbtests/executor_registry.cpp @@ -31,19 +31,21 @@ * ClientCursor::deregisterExecutor. */ +#include "mongo/platform/basic.h" + #include "mongo/client/dbclientcursor.h" #include "mongo/db/catalog/collection.h" #include "mongo/db/catalog/database.h" +#include "mongo/db/client.h" #include "mongo/db/db_raii.h" #include "mongo/db/dbdirectclient.h" #include "mongo/db/exec/collection_scan.h" #include "mongo/db/exec/plan_stage.h" -#include "mongo/db/service_context.h" #include "mongo/db/json.h" #include "mongo/db/matcher/expression_parser.h" #include "mongo/db/matcher/extensions_callback_disallow_extensions.h" -#include "mongo/db/operation_context_impl.h" #include "mongo/db/query/plan_executor.h" +#include "mongo/db/service_context.h" #include "mongo/dbtests/dbtests.h" namespace ExecutorRegistry { @@ -118,7 +120,8 @@ public: } // Order of these is important for initialization - OperationContextImpl _opCtx; + const ServiceContext::UniqueOperationContext _opCtxPtr = cc().makeOperationContext(); + OperationContext& _opCtx = *_opCtxPtr; unique_ptr<OldClientWriteContext> _ctx; DBDirectClient _client; }; diff --git a/src/mongo/dbtests/extensions_callback_real_test.cpp b/src/mongo/dbtests/extensions_callback_real_test.cpp index d1284f7aea4..abe62080fbe 100644 --- a/src/mongo/dbtests/extensions_callback_real_test.cpp +++ b/src/mongo/dbtests/extensions_callback_real_test.cpp @@ -28,12 +28,12 @@ #include "mongo/platform/basic.h" +#include "mongo/db/client.h" #include "mongo/db/db_raii.h" #include "mongo/db/json.h" #include "mongo/db/matcher/expression_text.h" #include "mongo/db/matcher/extensions_callback_real.h" #include "mongo/db/namespace_string.h" -#include "mongo/db/operation_context_impl.h" #include "mongo/dbtests/dbtests.h" #include "mongo/unittest/unittest.h" @@ -72,7 +72,8 @@ public: } protected: - OperationContextImpl _txn; + const ServiceContext::UniqueOperationContext _txnPtr = cc().makeOperationContext(); + OperationContext& _txn = *_txnPtr; const NamespaceString _nss; }; diff --git a/src/mongo/dbtests/framework_options.cpp b/src/mongo/dbtests/framework_options.cpp index 7a6d8867c64..c51bc34e00f 100644 --- a/src/mongo/dbtests/framework_options.cpp +++ b/src/mongo/dbtests/framework_options.cpp @@ -28,6 +28,9 @@ #define MONGO_LOG_DEFAULT_COMPONENT ::mongo::logger::LogComponent::kDefault +#include "mongo/platform/basic.h" + + #include "mongo/dbtests/framework_options.h" #include <boost/filesystem/operations.hpp> diff --git a/src/mongo/dbtests/framework_options_init.cpp b/src/mongo/dbtests/framework_options_init.cpp index d2764e6b46a..d6f0771d5dc 100644 --- a/src/mongo/dbtests/framework_options_init.cpp +++ b/src/mongo/dbtests/framework_options_init.cpp @@ -26,10 +26,11 @@ * then also delete it in the license file. */ -#include "mongo/dbtests/framework_options.h" +#include "mongo/platform/basic.h" #include <iostream> +#include "mongo/dbtests/framework_options.h" #include "mongo/util/options_parser/startup_option_init.h" #include "mongo/util/options_parser/startup_options.h" #include "mongo/util/quick_exit.h" diff --git a/src/mongo/dbtests/gle_test.cpp b/src/mongo/dbtests/gle_test.cpp index 4e01ed15c18..18c721a404f 100644 --- a/src/mongo/dbtests/gle_test.cpp +++ b/src/mongo/dbtests/gle_test.cpp @@ -26,8 +26,10 @@ * then also delete it in the license file. */ +#include "mongo/platform/basic.h" + +#include "mongo/db/client.h" #include "mongo/db/dbdirectclient.h" -#include "mongo/db/operation_context_impl.h" #include "mongo/dbtests/dbtests.h" #include "mongo/util/assert_util.h" @@ -48,7 +50,8 @@ static const char* const _ns = "unittests.gle"; class GetLastErrorCommandFailure { public: void run() { - OperationContextImpl txn; + const ServiceContext::UniqueOperationContext txnPtr = cc().makeOperationContext(); + OperationContext& txn = *txnPtr; DBDirectClient client(&txn); client.insert(_ns, @@ -67,7 +70,8 @@ public: class GetLastErrorClean { public: void run() { - OperationContextImpl txn; + const ServiceContext::UniqueOperationContext txnPtr = cc().makeOperationContext(); + OperationContext& txn = *txnPtr; DBDirectClient client(&txn); client.insert(_ns, @@ -86,7 +90,8 @@ public: class GetLastErrorFromDup { public: void run() { - OperationContextImpl txn; + const ServiceContext::UniqueOperationContext txnPtr = cc().makeOperationContext(); + OperationContext& txn = *txnPtr; DBDirectClient client(&txn); client.insert(_ns, BSON("_id" << 1)); diff --git a/src/mongo/dbtests/indexcatalogtests.cpp b/src/mongo/dbtests/indexcatalogtests.cpp index 39bea85d55e..23d6e6f092a 100644 --- a/src/mongo/dbtests/indexcatalogtests.cpp +++ b/src/mongo/dbtests/indexcatalogtests.cpp @@ -16,14 +16,16 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ +#include "mongo/platform/basic.h" + #include "mongo/db/catalog/collection.h" #include "mongo/db/catalog/collection_catalog_entry.h" #include "mongo/db/catalog/index_catalog.h" +#include "mongo/db/client.h" #include "mongo/db/db.h" #include "mongo/db/db_raii.h" #include "mongo/db/dbhelpers.h" #include "mongo/db/index/index_descriptor.h" -#include "mongo/db/operation_context_impl.h" #include "mongo/dbtests/dbtests.h" namespace IndexCatalogTests { @@ -33,7 +35,8 @@ static const char* const _ns = "unittests.indexcatalog"; class IndexIteratorTests { public: IndexIteratorTests() { - OperationContextImpl txn; + const ServiceContext::UniqueOperationContext txnPtr = cc().makeOperationContext(); + OperationContext& txn = *txnPtr; ScopedTransaction transaction(&txn, MODE_IX); Lock::DBLock lk(txn.lockState(), nsToDatabaseSubstring(_ns), MODE_X); OldClientContext ctx(&txn, _ns); @@ -46,7 +49,8 @@ public: } ~IndexIteratorTests() { - OperationContextImpl txn; + const ServiceContext::UniqueOperationContext txnPtr = cc().makeOperationContext(); + OperationContext& txn = *txnPtr; ScopedTransaction transaction(&txn, MODE_IX); Lock::DBLock lk(txn.lockState(), nsToDatabaseSubstring(_ns), MODE_X); OldClientContext ctx(&txn, _ns); @@ -57,7 +61,8 @@ public: } void run() { - OperationContextImpl txn; + const ServiceContext::UniqueOperationContext txnPtr = cc().makeOperationContext(); + OperationContext& txn = *txnPtr; OldClientWriteContext ctx(&txn, _ns); int numFinishedIndexesStart = _catalog->numIndexesReady(&txn); @@ -99,7 +104,8 @@ private: class RefreshEntry { public: RefreshEntry() { - OperationContextImpl txn; + const ServiceContext::UniqueOperationContext txnPtr = cc().makeOperationContext(); + OperationContext& txn = *txnPtr; ScopedTransaction transaction(&txn, MODE_IX); Lock::DBLock lk(txn.lockState(), nsToDatabaseSubstring(_ns), MODE_X); OldClientContext ctx(&txn, _ns); @@ -112,7 +118,8 @@ public: } ~RefreshEntry() { - OperationContextImpl txn; + const ServiceContext::UniqueOperationContext txnPtr = cc().makeOperationContext(); + OperationContext& txn = *txnPtr; ScopedTransaction transaction(&txn, MODE_IX); Lock::DBLock lk(txn.lockState(), nsToDatabaseSubstring(_ns), MODE_X); OldClientContext ctx(&txn, _ns); @@ -123,7 +130,8 @@ public: } void run() { - OperationContextImpl txn; + const ServiceContext::UniqueOperationContext txnPtr = cc().makeOperationContext(); + OperationContext& txn = *txnPtr; OldClientWriteContext ctx(&txn, _ns); const std::string indexName = "x_1"; diff --git a/src/mongo/dbtests/indexupdatetests.cpp b/src/mongo/dbtests/indexupdatetests.cpp index 9b16f7c2769..e81c45bdd94 100644 --- a/src/mongo/dbtests/indexupdatetests.cpp +++ b/src/mongo/dbtests/indexupdatetests.cpp @@ -28,18 +28,20 @@ * then also delete it in the license file. */ +#include "mongo/platform/basic.h" + #include <cstdint> #include "mongo/db/catalog/collection.h" #include "mongo/db/catalog/index_catalog.h" #include "mongo/db/catalog/index_create.h" +#include "mongo/db/client.h" #include "mongo/db/db_raii.h" #include "mongo/db/dbdirectclient.h" #include "mongo/db/dbhelpers.h" -#include "mongo/db/service_context_d.h" -#include "mongo/db/service_context.h" #include "mongo/db/index/index_descriptor.h" -#include "mongo/db/operation_context_impl.h" +#include "mongo/db/service_context.h" +#include "mongo/db/service_context_d.h" #include "mongo/dbtests/dbtests.h" namespace IndexUpdateTests { @@ -115,7 +117,8 @@ protected: return false; } - OperationContextImpl _txn; + const ServiceContext::UniqueOperationContext _txnPtr = cc().makeOperationContext(); + OperationContext& _txn = *_txnPtr; OldClientWriteContext _ctx; DBDirectClient _client; }; diff --git a/src/mongo/dbtests/jstests.cpp b/src/mongo/dbtests/jstests.cpp index fee13dde315..f3b64598fdc 100644 --- a/src/mongo/dbtests/jstests.cpp +++ b/src/mongo/dbtests/jstests.cpp @@ -37,9 +37,9 @@ #include <limits> #include "mongo/base/parse_number.h" +#include "mongo/db/client.h" #include "mongo/db/dbdirectclient.h" #include "mongo/db/json.h" -#include "mongo/db/operation_context_impl.h" #include "mongo/dbtests/dbtests.h" #include "mongo/platform/decimal128.h" #include "mongo/scripting/engine.h" @@ -986,7 +986,8 @@ public: string utf8ObjSpec = "{'_id':'\\u0001\\u007f\\u07ff\\uffff'}"; BSONObj utf8Obj = fromjson(utf8ObjSpec); - OperationContextImpl txn; + const ServiceContext::UniqueOperationContext txnPtr = cc().makeOperationContext(); + OperationContext& txn = *txnPtr; DBDirectClient client(&txn); client.insert(ns(), utf8Obj); @@ -1006,7 +1007,8 @@ private: } void reset() { - OperationContextImpl txn; + const ServiceContext::UniqueOperationContext txnPtr = cc().makeOperationContext(); + OperationContext& txn = *txnPtr; DBDirectClient client(&txn); client.dropCollection(ns()); @@ -1029,7 +1031,8 @@ public: if (!globalScriptEngine->utf8Ok()) return; - OperationContextImpl txn; + const ServiceContext::UniqueOperationContext txnPtr = cc().makeOperationContext(); + OperationContext& txn = *txnPtr; DBDirectClient client(&txn); client.eval("unittest", @@ -1038,7 +1041,8 @@ public: private: void reset() { - OperationContextImpl txn; + const ServiceContext::UniqueOperationContext txnPtr = cc().makeOperationContext(); + OperationContext& txn = *txnPtr; DBDirectClient client(&txn); client.dropCollection(ns()); @@ -1117,7 +1121,8 @@ public: // Insert in Javascript -> Find using DBDirectClient // Drop the collection - OperationContextImpl txn; + const ServiceContext::UniqueOperationContext txnPtr = cc().makeOperationContext(); + OperationContext& txn = *txnPtr; DBDirectClient client(&txn); client.dropCollection("unittest.testroundtrip"); @@ -2225,7 +2230,8 @@ public: update.appendCode("value", "function () { db.test.find().forEach(function(obj) { continue; }); }"); - OperationContextImpl txn; + const ServiceContext::UniqueOperationContext txnPtr = cc().makeOperationContext(); + OperationContext& txn = *txnPtr; DBDirectClient client(&txn); client.update("test.system.js", query.obj(), update.obj(), true /* upsert */); diff --git a/src/mongo/dbtests/matchertests.cpp b/src/mongo/dbtests/matchertests.cpp index fc2ca4049c6..ef4c6498384 100644 --- a/src/mongo/dbtests/matchertests.cpp +++ b/src/mongo/dbtests/matchertests.cpp @@ -29,14 +29,16 @@ * then also delete it in the license file. */ +#include "mongo/platform/basic.h" + #include <iostream> +#include "mongo/db/client.h" #include "mongo/db/db_raii.h" #include "mongo/db/json.h" #include "mongo/db/matcher/extensions_callback_disallow_extensions.h" #include "mongo/db/matcher/extensions_callback_real.h" #include "mongo/db/matcher/matcher.h" -#include "mongo/db/operation_context_impl.h" #include "mongo/dbtests/dbtests.h" #include "mongo/util/timer.h" @@ -213,7 +215,8 @@ template <typename M> class WhereSimple1 { public: void run() { - OperationContextImpl txn; + const ServiceContext::UniqueOperationContext txnPtr = cc().makeOperationContext(); + OperationContext& txn = *txnPtr; const NamespaceString nss("unittests.matchertests"); AutoGetCollectionForRead ctx(&txn, nss); diff --git a/src/mongo/dbtests/mock_dbclient_conn_test.cpp b/src/mongo/dbtests/mock_dbclient_conn_test.cpp index 7dd6520cd2e..60a5dba7220 100644 --- a/src/mongo/dbtests/mock_dbclient_conn_test.cpp +++ b/src/mongo/dbtests/mock_dbclient_conn_test.cpp @@ -29,6 +29,8 @@ * This file includes integration testing between the MockDBClientBase and MockRemoteDB. */ +#include "mongo/platform/basic.h" + #include "mongo/client/dbclientinterface.h" #include "mongo/db/jsobj.h" #include "mongo/dbtests/mock/mock_dbclient_connection.h" diff --git a/src/mongo/dbtests/mock_replica_set_test.cpp b/src/mongo/dbtests/mock_replica_set_test.cpp index 3b0ac16074c..0ead3d418ab 100644 --- a/src/mongo/dbtests/mock_replica_set_test.cpp +++ b/src/mongo/dbtests/mock_replica_set_test.cpp @@ -25,6 +25,8 @@ * then also delete it in the license file. */ +#include "mongo/platform/basic.h" + #include "mongo/client/dbclientinterface.h" #include "mongo/dbtests/mock/mock_replica_set.h" #include "mongo/unittest/unittest.h" diff --git a/src/mongo/dbtests/namespacetests.cpp b/src/mongo/dbtests/namespacetests.cpp index f83f5335e53..eadb0a4d85e 100644 --- a/src/mongo/dbtests/namespacetests.cpp +++ b/src/mongo/dbtests/namespacetests.cpp @@ -37,12 +37,12 @@ #include "mongo/db/catalog/collection.h" #include "mongo/db/catalog/database_holder.h" +#include "mongo/db/client.h" #include "mongo/db/db_raii.h" #include "mongo/db/index/expression_keys_private.h" #include "mongo/db/index_legacy.h" #include "mongo/db/index_names.h" #include "mongo/db/json.h" -#include "mongo/db/operation_context_impl.h" #include "mongo/db/query/internal_plans.h" #include "mongo/db/storage/mmap_v1/catalog/namespace.h" #include "mongo/db/storage/mmap_v1/catalog/namespace_details.h" @@ -68,7 +68,8 @@ namespace MissingFieldTests { class BtreeIndexMissingField { public: void run() { - OperationContextImpl txn; + const ServiceContext::UniqueOperationContext txnPtr = cc().makeOperationContext(); + OperationContext& txn = *txnPtr; BSONObj spec(BSON("key" << BSON("a" << 1))); ASSERT_EQUALS(jstNULL, IndexLegacy::getMissingField(&txn, NULL, spec).firstElement().type()); @@ -79,7 +80,8 @@ public: class TwoDIndexMissingField { public: void run() { - OperationContextImpl txn; + const ServiceContext::UniqueOperationContext txnPtr = cc().makeOperationContext(); + OperationContext& txn = *txnPtr; BSONObj spec(BSON("key" << BSON("a" << "2d"))); ASSERT_EQUALS(jstNULL, @@ -91,7 +93,8 @@ public: class HashedIndexMissingField { public: void run() { - OperationContextImpl txn; + const ServiceContext::UniqueOperationContext txnPtr = cc().makeOperationContext(); + OperationContext& txn = *txnPtr; BSONObj spec(BSON("key" << BSON("a" << "hashed"))); BSONObj nullObj = BSON("a" << BSONNULL); @@ -117,7 +120,8 @@ public: class HashedIndexMissingFieldAlternateSeed { public: void run() { - OperationContextImpl txn; + const ServiceContext::UniqueOperationContext txnPtr = cc().makeOperationContext(); + OperationContext& txn = *txnPtr; BSONObj spec(BSON("key" << BSON("a" << "hashed") << "seed" << 0x5eed)); BSONObj nullObj = BSON("a" << BSONNULL); @@ -149,7 +153,7 @@ namespace NamespaceDetailsTests { public: Base( const char *ns = "unittests.NamespaceDetailsTests" ) : ns_( ns ) , _context( ns ) {} virtual ~Base() { - OperationContextImpl txn; + const ServiceContext::UniqueOperationContext txnPtr = cc().makeOperationContext(); OperationContext& txn = *txnPtr; if ( !nsd() ) return; _context.db()->dropCollection( &txn, ns() ); @@ -157,7 +161,7 @@ namespace NamespaceDetailsTests { protected: void create() { Lock::GlobalWrite lk; - OperationContextImpl txn; + const ServiceContext::UniqueOperationContext txnPtr = cc().makeOperationContext(); OperationContext& txn = *txnPtr; ASSERT( userCreateNS( &txn, db(), ns(), fromjson( spec() ), false ).isOK() ); } virtual string spec() const = 0; @@ -240,7 +244,7 @@ namespace NamespaceDetailsTests { class SingleAlloc : public Base { public: void run() { - OperationContextImpl txn; + const ServiceContext::UniqueOperationContext txnPtr = cc().makeOperationContext(); OperationContext& txn = *txnPtr; create(); BSONObj b = bigObj(); ASSERT( collection()->insertDocument( &txn, b, true ).isOK() ); @@ -252,7 +256,7 @@ namespace NamespaceDetailsTests { class Realloc : public Base { public: void run() { - OperationContextImpl txn; + const ServiceContext::UniqueOperationContext txnPtr = cc().makeOperationContext(); OperationContext& txn = *txnPtr; create(); const int N = 20; @@ -277,7 +281,7 @@ namespace NamespaceDetailsTests { class TwoExtent : public Base { public: void run() { - OperationContextImpl txn; + const ServiceContext::UniqueOperationContext txnPtr = cc().makeOperationContext(); OperationContext& txn = *txnPtr; create(); ASSERT_EQUALS( 2, nExtents() ); @@ -325,7 +329,7 @@ namespace NamespaceDetailsTests { class AllocCappedNotQuantized : public Base { public: void run() { - OperationContextImpl txn; + const ServiceContext::UniqueOperationContext txnPtr = cc().makeOperationContext(); OperationContext& txn = *txnPtr; create(); ASSERT( nsd()->isCapped() ); ASSERT( !nsd()->isUserFlagSet( NamespaceDetails::Flag_UsePowerOf2Sizes ) ); @@ -348,7 +352,7 @@ namespace NamespaceDetailsTests { return "{\"capped\":true,\"size\":512,\"$nExtents\":2}"; } void pass(int p) { - OperationContextImpl txn; + const ServiceContext::UniqueOperationContext txnPtr = cc().makeOperationContext(); OperationContext& txn = *txnPtr; create(); ASSERT_EQUALS( 2, nExtents() ); @@ -493,7 +497,7 @@ namespace NamespaceDetailsTests { create(); NamespaceDetails *nsd = collection()->detailsWritable(); - OperationContextImpl txn; + const ServiceContext::UniqueOperationContext txnPtr = cc().makeOperationContext(); OperationContext& txn = *txnPtr; // Set 2 & 54 as multikey nsd->setIndexIsMultikey(&txn, 2, true); nsd->setIndexIsMultikey(&txn, 54, true); @@ -534,7 +538,8 @@ public: const string committedName = dbName + ".committed"; const string rolledBackName = dbName + ".rolled_back"; - OperationContextImpl txn; + const ServiceContext::UniqueOperationContext txnPtr = cc().makeOperationContext(); + OperationContext& txn = *txnPtr; ScopedTransaction transaction(&txn, MODE_IX); Lock::DBLock lk(txn.lockState(), dbName, MODE_X); @@ -578,7 +583,8 @@ public: const string droppedName = dbName + ".dropped"; const string rolledBackName = dbName + ".rolled_back"; - OperationContextImpl txn; + const ServiceContext::UniqueOperationContext txnPtr = cc().makeOperationContext(); + OperationContext& txn = *txnPtr; ScopedTransaction transaction(&txn, MODE_IX); Lock::DBLock lk(txn.lockState(), dbName, MODE_X); diff --git a/src/mongo/dbtests/oplogstarttests.cpp b/src/mongo/dbtests/oplogstarttests.cpp index ddb6422fc86..b1bfad6b010 100644 --- a/src/mongo/dbtests/oplogstarttests.cpp +++ b/src/mongo/dbtests/oplogstarttests.cpp @@ -20,20 +20,20 @@ * be replayed from for replication. */ -#include "mongo/dbtests/dbtests.h" - +#include "mongo/platform/basic.h" #include "mongo/db/catalog/collection.h" +#include "mongo/db/client.h" #include "mongo/db/db.h" #include "mongo/db/db_raii.h" #include "mongo/db/dbdirectclient.h" #include "mongo/db/exec/oplogstart.h" #include "mongo/db/exec/working_set.h" #include "mongo/db/matcher/extensions_callback_disallow_extensions.h" -#include "mongo/db/service_context.h" -#include "mongo/db/operation_context_impl.h" #include "mongo/db/query/canonical_query.h" #include "mongo/db/repl/repl_settings.h" +#include "mongo/db/service_context.h" +#include "mongo/dbtests/dbtests.h" namespace OplogStartTests { @@ -45,8 +45,7 @@ static const NamespaceString nss("unittests.oplogstarttests"); class Base { public: Base() - : _txn(), - _scopedXact(&_txn, MODE_X), + : _scopedXact(&_txn, MODE_X), _lk(_txn.lockState()), _context(&_txn, nss.ns()), _client(&_txn) { @@ -98,7 +97,8 @@ protected: private: // The order of these is important in order to ensure order of destruction - OperationContextImpl _txn; + const ServiceContext::UniqueOperationContext _txnPtr = cc().makeOperationContext(); + OperationContext& _txn = *_txnPtr; ScopedTransaction _scopedXact; Lock::GlobalWrite _lk; OldClientContext _context; diff --git a/src/mongo/dbtests/pdfiletests.cpp b/src/mongo/dbtests/pdfiletests.cpp index f4955d67edd..943f0a124fd 100644 --- a/src/mongo/dbtests/pdfiletests.cpp +++ b/src/mongo/dbtests/pdfiletests.cpp @@ -32,10 +32,10 @@ #include "mongo/platform/basic.h" #include "mongo/db/catalog/collection.h" +#include "mongo/db/client.h" #include "mongo/db/db.h" #include "mongo/db/db_raii.h" #include "mongo/db/json.h" -#include "mongo/db/operation_context_impl.h" #include "mongo/db/ops/insert.h" #include "mongo/dbtests/dbtests.h" @@ -62,7 +62,8 @@ protected: return _context.db()->getCollection(ns()); } - OperationContextImpl _txn; + const ServiceContext::UniqueOperationContext _txnPtr = cc().makeOperationContext(); + OperationContext& _txn = *_txnPtr; ScopedTransaction _scopedXact; Lock::GlobalWrite _lk; OldClientContext _context; diff --git a/src/mongo/dbtests/perftests.cpp b/src/mongo/dbtests/perftests.cpp index 33aa029996b..3c62cffc5f3 100644 --- a/src/mongo/dbtests/perftests.cpp +++ b/src/mongo/dbtests/perftests.cpp @@ -51,7 +51,6 @@ #include "mongo/db/db.h" #include "mongo/db/dbdirectclient.h" #include "mongo/db/lasterror.h" -#include "mongo/db/operation_context_impl.h" #include "mongo/db/storage/mmap_v1/dur_stats.h" #include "mongo/db/storage/mmap_v1/mmap.h" #include "mongo/db/storage/storage_options.h" @@ -106,7 +105,8 @@ protected: } private: - OperationContextImpl _txn; + const ServiceContext::UniqueOperationContext _txnPtr = cc().makeOperationContext(); + OperationContext& _txn = *_txnPtr; DBDirectClient _client; }; @@ -327,7 +327,8 @@ public: srand(++z ^ (unsigned)time(0)); #endif Client::initThreadIfNotAlready("perftestthr"); - OperationContextImpl txn; + const ServiceContext::UniqueOperationContext txnPtr = cc().makeOperationContext(); + OperationContext& txn = *txnPtr; DBDirectClient c(&txn); const unsigned int Batch = batchSize(); diff --git a/src/mongo/dbtests/plan_ranking.cpp b/src/mongo/dbtests/plan_ranking.cpp index 5012816caa4..9c9d52bccf4 100644 --- a/src/mongo/dbtests/plan_ranking.cpp +++ b/src/mongo/dbtests/plan_ranking.cpp @@ -30,18 +30,20 @@ * This file tests db/query/plan_ranker.cpp and db/query/multi_plan_runner.cpp. */ +#include "mongo/platform/basic.h" + #include <iostream> #include "mongo/client/dbclientcursor.h" #include "mongo/db/catalog/collection.h" #include "mongo/db/catalog/database.h" +#include "mongo/db/client.h" #include "mongo/db/db_raii.h" #include "mongo/db/dbdirectclient.h" #include "mongo/db/exec/multi_plan.h" #include "mongo/db/index/index_descriptor.h" #include "mongo/db/json.h" #include "mongo/db/matcher/extensions_callback_disallow_extensions.h" -#include "mongo/db/operation_context_impl.h" #include "mongo/db/query/get_executor.h" #include "mongo/db/query/query_knobs.h" #include "mongo/db/query/query_planner.h" @@ -152,7 +154,8 @@ protected: // determining the number of documents in the tests below. static const int N; - OperationContextImpl _txn; + const ServiceContext::UniqueOperationContext _txnPtr = cc().makeOperationContext(); + OperationContext& _txn = *_txnPtr; private: // Holds the value of global "internalQueryForceIntersectionPlans" setParameter flag. diff --git a/src/mongo/dbtests/query_plan_executor.cpp b/src/mongo/dbtests/query_plan_executor.cpp index 744ec5cb461..ffc2557cda4 100644 --- a/src/mongo/dbtests/query_plan_executor.cpp +++ b/src/mongo/dbtests/query_plan_executor.cpp @@ -27,8 +27,11 @@ */ +#include "mongo/platform/basic.h" + #include "mongo/db/catalog/collection.h" #include "mongo/db/catalog/database.h" +#include "mongo/db/client.h" #include "mongo/db/clientcursor.h" #include "mongo/db/db_raii.h" #include "mongo/db/dbdirectclient.h" @@ -41,7 +44,6 @@ #include "mongo/db/json.h" #include "mongo/db/matcher/expression_parser.h" #include "mongo/db/matcher/extensions_callback_disallow_extensions.h" -#include "mongo/db/operation_context_impl.h" #include "mongo/db/pipeline/expression_context.h" #include "mongo/db/pipeline/pipeline.h" #include "mongo/db/query/plan_executor.h" @@ -185,7 +187,8 @@ public: } protected: - OperationContextImpl _txn; + const ServiceContext::UniqueOperationContext _txnPtr = cc().makeOperationContext(); + OperationContext& _txn = *_txnPtr; private: IndexDescriptor* getIndex(Database* db, const BSONObj& obj) { diff --git a/src/mongo/dbtests/query_stage_and.cpp b/src/mongo/dbtests/query_stage_and.cpp index 1b9ada903e4..365b58f6ef0 100644 --- a/src/mongo/dbtests/query_stage_and.cpp +++ b/src/mongo/dbtests/query_stage_and.cpp @@ -32,9 +32,12 @@ */ +#include "mongo/platform/basic.h" + #include "mongo/client/dbclientcursor.h" #include "mongo/db/catalog/collection.h" #include "mongo/db/catalog/database.h" +#include "mongo/db/client.h" #include "mongo/db/db_raii.h" #include "mongo/db/dbdirectclient.h" #include "mongo/db/exec/and_hash.h" @@ -45,7 +48,6 @@ #include "mongo/db/exec/queued_data_stage.h" #include "mongo/db/json.h" #include "mongo/db/matcher/expression_parser.h" -#include "mongo/db/operation_context_impl.h" #include "mongo/dbtests/dbtests.h" #include "mongo/stdx/memory.h" #include "mongo/util/mongoutils/str.h" @@ -147,7 +149,8 @@ public: } protected: - OperationContextImpl _txn; + const ServiceContext::UniqueOperationContext _txnPtr = cc().makeOperationContext(); + OperationContext& _txn = *_txnPtr; private: DBDirectClient _client; diff --git a/src/mongo/dbtests/query_stage_cached_plan.cpp b/src/mongo/dbtests/query_stage_cached_plan.cpp index 132859afb92..be91a55fdf1 100644 --- a/src/mongo/dbtests/query_stage_cached_plan.cpp +++ b/src/mongo/dbtests/query_stage_cached_plan.cpp @@ -26,17 +26,19 @@ * then also delete it in the license file. */ +#include "mongo/platform/basic.h" + #include "mongo/bson/bsonobjbuilder.h" #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/db_raii.h" #include "mongo/db/exec/cached_plan.h" #include "mongo/db/exec/queued_data_stage.h" -#include "mongo/db/db_raii.h" #include "mongo/db/jsobj.h" #include "mongo/db/json.h" #include "mongo/db/matcher/extensions_callback_disallow_extensions.h" -#include "mongo/db/operation_context_impl.h" #include "mongo/db/query/canonical_query.h" #include "mongo/db/query/get_executor.h" #include "mongo/db/query/plan_cache.h" @@ -96,7 +98,8 @@ public: } protected: - OperationContextImpl _txn; + const ServiceContext::UniqueOperationContext _txnPtr = cc().makeOperationContext(); + OperationContext& _txn = *_txnPtr; WorkingSet _ws; }; diff --git a/src/mongo/dbtests/query_stage_collscan.cpp b/src/mongo/dbtests/query_stage_collscan.cpp index 5154470fad4..c233155af77 100644 --- a/src/mongo/dbtests/query_stage_collscan.cpp +++ b/src/mongo/dbtests/query_stage_collscan.cpp @@ -30,10 +30,12 @@ * This file tests db/exec/collection_scan.cpp. */ +#include "mongo/platform/basic.h" #include "mongo/client/dbclientcursor.h" #include "mongo/db/catalog/collection.h" #include "mongo/db/catalog/database.h" +#include "mongo/db/client.h" #include "mongo/db/db_raii.h" #include "mongo/db/dbdirectclient.h" #include "mongo/db/exec/collection_scan.h" @@ -41,7 +43,6 @@ #include "mongo/db/json.h" #include "mongo/db/matcher/expression_parser.h" #include "mongo/db/matcher/extensions_callback_disallow_extensions.h" -#include "mongo/db/operation_context_impl.h" #include "mongo/db/query/plan_executor.h" #include "mongo/db/storage/record_store.h" #include "mongo/dbtests/dbtests.h" @@ -145,7 +146,8 @@ public: } protected: - OperationContextImpl _txn; + const ServiceContext::UniqueOperationContext _txnPtr = cc().makeOperationContext(); + OperationContext& _txn = *_txnPtr; private: DBDirectClient _client; diff --git a/src/mongo/dbtests/query_stage_count.cpp b/src/mongo/dbtests/query_stage_count.cpp index cfdcf6ffab8..de3d484dbaa 100644 --- a/src/mongo/dbtests/query_stage_count.cpp +++ b/src/mongo/dbtests/query_stage_count.cpp @@ -28,6 +28,9 @@ #include <memory> +#include "mongo/platform/basic.h" + +#include "mongo/db/client.h" #include "mongo/db/db_raii.h" #include "mongo/db/exec/collection_scan.h" #include "mongo/db/exec/collection_scan_common.h" @@ -38,7 +41,6 @@ #include "mongo/db/matcher/expression.h" #include "mongo/db/matcher/expression_parser.h" #include "mongo/db/matcher/extensions_callback_disallow_extensions.h" -#include "mongo/db/operation_context_impl.h" #include "mongo/dbtests/dbtests.h" namespace QueryStageCount { @@ -52,8 +54,7 @@ const int kInterjections = kDocuments; class CountStageTest { public: CountStageTest() - : _txn(), - _scopedXact(&_txn, MODE_IX), + : _scopedXact(&_txn, MODE_IX), _dbLock(_txn.lockState(), nsToDatabaseSubstring(ns()), MODE_X), _ctx(&_txn, ns()), _coll(NULL) {} @@ -224,7 +225,8 @@ public: protected: vector<RecordId> _recordIds; - OperationContextImpl _txn; + const ServiceContext::UniqueOperationContext _txnPtr = cc().makeOperationContext(); + OperationContext& _txn = *_txnPtr; ScopedTransaction _scopedXact; Lock::DBLock _dbLock; OldClientContext _ctx; diff --git a/src/mongo/dbtests/query_stage_count_scan.cpp b/src/mongo/dbtests/query_stage_count_scan.cpp index e499e06cbdc..67f20ce4d0f 100644 --- a/src/mongo/dbtests/query_stage_count_scan.cpp +++ b/src/mongo/dbtests/query_stage_count_scan.cpp @@ -27,9 +27,12 @@ */ +#include "mongo/platform/basic.h" + #include "mongo/client/dbclientcursor.h" #include "mongo/db/catalog/collection.h" #include "mongo/db/catalog/database.h" +#include "mongo/db/client.h" #include "mongo/db/db_raii.h" #include "mongo/db/dbdirectclient.h" #include "mongo/db/exec/collection_scan.h" @@ -38,7 +41,6 @@ #include "mongo/db/exec/working_set.h" #include "mongo/db/json.h" #include "mongo/db/matcher/expression_parser.h" -#include "mongo/db/operation_context_impl.h" #include "mongo/dbtests/dbtests.h" #include "mongo/util/fail_point.h" #include "mongo/util/fail_point_registry.h" @@ -98,7 +100,8 @@ public: } protected: - OperationContextImpl _txn; + const ServiceContext::UniqueOperationContext _txnPtr = cc().makeOperationContext(); + OperationContext& _txn = *_txnPtr; private: DBDirectClient _client; diff --git a/src/mongo/dbtests/query_stage_delete.cpp b/src/mongo/dbtests/query_stage_delete.cpp index c35536708ca..4c3e2b873aa 100644 --- a/src/mongo/dbtests/query_stage_delete.cpp +++ b/src/mongo/dbtests/query_stage_delete.cpp @@ -30,9 +30,11 @@ * This file tests db/exec/delete.cpp. */ +#include "mongo/platform/basic.h" #include "mongo/db/catalog/collection.h" #include "mongo/db/catalog/database.h" +#include "mongo/db/client.h" #include "mongo/db/concurrency/write_conflict_exception.h" #include "mongo/db/db_raii.h" #include "mongo/db/dbdirectclient.h" @@ -40,7 +42,6 @@ #include "mongo/db/exec/delete.h" #include "mongo/db/exec/queued_data_stage.h" #include "mongo/db/matcher/extensions_callback_disallow_extensions.h" -#include "mongo/db/operation_context_impl.h" #include "mongo/db/query/canonical_query.h" #include "mongo/db/service_context.h" #include "mongo/dbtests/dbtests.h" @@ -114,7 +115,8 @@ public: } protected: - OperationContextImpl _txn; + const ServiceContext::UniqueOperationContext _txnPtr = cc().makeOperationContext(); + OperationContext& _txn = *_txnPtr; private: DBDirectClient _client; diff --git a/src/mongo/dbtests/query_stage_distinct.cpp b/src/mongo/dbtests/query_stage_distinct.cpp index 43c3d3b7fe8..417fd317362 100644 --- a/src/mongo/dbtests/query_stage_distinct.cpp +++ b/src/mongo/dbtests/query_stage_distinct.cpp @@ -26,15 +26,17 @@ * then also delete it in the license file. */ +#include "mongo/platform/basic.h" + #include "mongo/client/dbclientcursor.h" #include "mongo/db/catalog/collection.h" #include "mongo/db/catalog/database.h" +#include "mongo/db/client.h" #include "mongo/db/db_raii.h" #include "mongo/db/dbdirectclient.h" #include "mongo/db/exec/distinct_scan.h" #include "mongo/db/exec/plan_stage.h" #include "mongo/db/json.h" -#include "mongo/db/operation_context_impl.h" #include "mongo/db/query/index_bounds_builder.h" #include "mongo/db/query/plan_executor.h" #include "mongo/dbtests/dbtests.h" @@ -93,7 +95,8 @@ public: } protected: - OperationContextImpl _txn; + const ServiceContext::UniqueOperationContext _txnPtr = cc().makeOperationContext(); + OperationContext& _txn = *_txnPtr; private: DBDirectClient _client; diff --git a/src/mongo/dbtests/query_stage_fetch.cpp b/src/mongo/dbtests/query_stage_fetch.cpp index 079be7c5244..451b4b3069a 100644 --- a/src/mongo/dbtests/query_stage_fetch.cpp +++ b/src/mongo/dbtests/query_stage_fetch.cpp @@ -30,10 +30,12 @@ * This file tests db/exec/fetch.cpp. Fetch goes to disk so we cannot test outside of a dbtest. */ +#include "mongo/platform/basic.h" #include "mongo/client/dbclientcursor.h" #include "mongo/db/catalog/collection.h" #include "mongo/db/catalog/database.h" +#include "mongo/db/client.h" #include "mongo/db/db_raii.h" #include "mongo/db/dbdirectclient.h" #include "mongo/db/exec/fetch.h" @@ -42,7 +44,6 @@ #include "mongo/db/json.h" #include "mongo/db/matcher/expression_parser.h" #include "mongo/db/matcher/extensions_callback_disallow_extensions.h" -#include "mongo/db/operation_context_impl.h" #include "mongo/dbtests/dbtests.h" #include "mongo/stdx/memory.h" @@ -81,7 +82,8 @@ public: } protected: - OperationContextImpl _txn; + const ServiceContext::UniqueOperationContext _txnPtr = cc().makeOperationContext(); + OperationContext& _txn = *_txnPtr; DBDirectClient _client; }; diff --git a/src/mongo/dbtests/query_stage_ixscan.cpp b/src/mongo/dbtests/query_stage_ixscan.cpp index 97f77af78e6..12e8f33fb3c 100644 --- a/src/mongo/dbtests/query_stage_ixscan.cpp +++ b/src/mongo/dbtests/query_stage_ixscan.cpp @@ -34,7 +34,6 @@ #include "mongo/db/exec/working_set.h" #include "mongo/db/jsobj.h" #include "mongo/db/json.h" -#include "mongo/db/operation_context_impl.h" #include "mongo/dbtests/dbtests.h" namespace QueryStageIxscan { @@ -42,8 +41,7 @@ namespace QueryStageIxscan { class IndexScanTest { public: IndexScanTest() - : _txn(), - _scopedXact(&_txn, MODE_IX), + : _scopedXact(&_txn, MODE_IX), _dbLock(_txn.lockState(), nsToDatabaseSubstring(ns()), MODE_X), _ctx(&_txn, ns()), _coll(NULL) {} @@ -139,7 +137,8 @@ public: } protected: - OperationContextImpl _txn; + const ServiceContext::UniqueOperationContext _txnPtr = cc().makeOperationContext(); + OperationContext& _txn = *_txnPtr; ScopedTransaction _scopedXact; Lock::DBLock _dbLock; diff --git a/src/mongo/dbtests/query_stage_keep.cpp b/src/mongo/dbtests/query_stage_keep.cpp index a304a13ae2a..56c8c1d7387 100644 --- a/src/mongo/dbtests/query_stage_keep.cpp +++ b/src/mongo/dbtests/query_stage_keep.cpp @@ -30,10 +30,12 @@ * This file tests db/exec/keep_mutations.cpp. */ +#include "mongo/platform/basic.h" #include "mongo/client/dbclientcursor.h" #include "mongo/db/catalog/collection.h" #include "mongo/db/catalog/database.h" +#include "mongo/db/client.h" #include "mongo/db/db_raii.h" #include "mongo/db/dbdirectclient.h" #include "mongo/db/exec/collection_scan.h" @@ -43,12 +45,11 @@ #include "mongo/db/exec/working_set.h" #include "mongo/db/json.h" #include "mongo/db/matcher/expression_parser.h" -#include "mongo/db/operation_context_impl.h" #include "mongo/dbtests/dbtests.h" +#include "mongo/stdx/memory.h" #include "mongo/util/fail_point.h" #include "mongo/util/fail_point_registry.h" #include "mongo/util/fail_point_service.h" -#include "mongo/stdx/memory.h" namespace QueryStageKeep { @@ -96,7 +97,8 @@ public: } protected: - OperationContextImpl _txn; + const ServiceContext::UniqueOperationContext _txnPtr = cc().makeOperationContext(); + OperationContext& _txn = *_txnPtr; DBDirectClient _client; }; diff --git a/src/mongo/dbtests/query_stage_limit_skip.cpp b/src/mongo/dbtests/query_stage_limit_skip.cpp index 39c04796fea..2bb8e3b1faf 100644 --- a/src/mongo/dbtests/query_stage_limit_skip.cpp +++ b/src/mongo/dbtests/query_stage_limit_skip.cpp @@ -31,6 +31,8 @@ */ +#include "mongo/platform/basic.h" + #include "mongo/client/dbclientcursor.h" #include "mongo/db/exec/limit.h" #include "mongo/db/exec/plan_stage.h" diff --git a/src/mongo/dbtests/query_stage_merge_sort.cpp b/src/mongo/dbtests/query_stage_merge_sort.cpp index 5a4ebe4f02e..841d2ea56f7 100644 --- a/src/mongo/dbtests/query_stage_merge_sort.cpp +++ b/src/mongo/dbtests/query_stage_merge_sort.cpp @@ -26,9 +26,12 @@ * then also delete it in the license file. */ +#include "mongo/platform/basic.h" + #include "mongo/client/dbclientcursor.h" #include "mongo/db/catalog/collection.h" #include "mongo/db/catalog/database.h" +#include "mongo/db/client.h" #include "mongo/db/db_raii.h" #include "mongo/db/dbdirectclient.h" #include "mongo/db/exec/fetch.h" @@ -36,7 +39,6 @@ #include "mongo/db/exec/merge_sort.h" #include "mongo/db/exec/plan_stage.h" #include "mongo/db/json.h" -#include "mongo/db/operation_context_impl.h" #include "mongo/db/query/collation/collator_interface_mock.h" #include "mongo/db/query/plan_executor.h" #include "mongo/dbtests/dbtests.h" @@ -104,7 +106,8 @@ public: } protected: - OperationContextImpl _txn; + const ServiceContext::UniqueOperationContext _txnPtr = cc().makeOperationContext(); + OperationContext& _txn = *_txnPtr; private: DBDirectClient _client; diff --git a/src/mongo/dbtests/query_stage_multiplan.cpp b/src/mongo/dbtests/query_stage_multiplan.cpp index 9ccc6fe91ee..a26a657d4b5 100644 --- a/src/mongo/dbtests/query_stage_multiplan.cpp +++ b/src/mongo/dbtests/query_stage_multiplan.cpp @@ -26,8 +26,11 @@ * then also delete it in the license file. */ +#include "mongo/platform/basic.h" + #include "mongo/db/catalog/collection.h" #include "mongo/db/catalog/database.h" +#include "mongo/db/client.h" #include "mongo/db/db_raii.h" #include "mongo/db/dbdirectclient.h" #include "mongo/db/exec/collection_scan.h" @@ -39,7 +42,6 @@ #include "mongo/db/json.h" #include "mongo/db/matcher/expression_parser.h" #include "mongo/db/matcher/extensions_callback_disallow_extensions.h" -#include "mongo/db/operation_context_impl.h" #include "mongo/db/query/get_executor.h" #include "mongo/db/query/plan_executor.h" #include "mongo/db/query/query_knobs.h" @@ -102,7 +104,8 @@ public: } protected: - OperationContextImpl _txn; + const ServiceContext::UniqueOperationContext _txnPtr = cc().makeOperationContext(); + OperationContext& _txn = *_txnPtr; DBDirectClient _client; }; diff --git a/src/mongo/dbtests/query_stage_near.cpp b/src/mongo/dbtests/query_stage_near.cpp index 1d114dbf58f..58833e6a2bf 100644 --- a/src/mongo/dbtests/query_stage_near.cpp +++ b/src/mongo/dbtests/query_stage_near.cpp @@ -31,6 +31,8 @@ */ +#include "mongo/platform/basic.h" + #include "mongo/base/owned_pointer_vector.h" #include "mongo/db/exec/near.h" #include "mongo/db/exec/queued_data_stage.h" diff --git a/src/mongo/dbtests/query_stage_sort.cpp b/src/mongo/dbtests/query_stage_sort.cpp index e82333b40d6..676da68abcd 100644 --- a/src/mongo/dbtests/query_stage_sort.cpp +++ b/src/mongo/dbtests/query_stage_sort.cpp @@ -26,9 +26,12 @@ * then also delete it in the license file. */ +#include "mongo/platform/basic.h" + #include "mongo/client/dbclientcursor.h" #include "mongo/db/catalog/collection.h" #include "mongo/db/catalog/database.h" +#include "mongo/db/client.h" #include "mongo/db/db_raii.h" #include "mongo/db/dbdirectclient.h" #include "mongo/db/exec/fetch.h" @@ -36,7 +39,6 @@ #include "mongo/db/exec/queued_data_stage.h" #include "mongo/db/exec/sort.h" #include "mongo/db/json.h" -#include "mongo/db/operation_context_impl.h" #include "mongo/db/query/plan_executor.h" #include "mongo/dbtests/dbtests.h" #include "mongo/stdx/memory.h" @@ -216,7 +218,8 @@ public: } protected: - OperationContextImpl _txn; + const ServiceContext::UniqueOperationContext _txnPtr = cc().makeOperationContext(); + OperationContext& _txn = *_txnPtr; DBDirectClient _client; }; diff --git a/src/mongo/dbtests/query_stage_subplan.cpp b/src/mongo/dbtests/query_stage_subplan.cpp index 7a61f48a873..a5253a5ee94 100644 --- a/src/mongo/dbtests/query_stage_subplan.cpp +++ b/src/mongo/dbtests/query_stage_subplan.cpp @@ -32,6 +32,7 @@ #include "mongo/db/catalog/collection.h" #include "mongo/db/catalog/database.h" +#include "mongo/db/client.h" #include "mongo/db/db_raii.h" #include "mongo/db/dbdirectclient.h" #include "mongo/db/exec/subplan.h" @@ -39,7 +40,6 @@ #include "mongo/db/json.h" #include "mongo/db/matcher/extensions_callback_disallow_extensions.h" #include "mongo/db/matcher/extensions_callback_noop.h" -#include "mongo/db/operation_context_impl.h" #include "mongo/db/query/canonical_query.h" #include "mongo/db/query/get_executor.h" #include "mongo/dbtests/dbtests.h" @@ -81,7 +81,8 @@ protected: return cq; } - OperationContextImpl _txn; + const ServiceContext::UniqueOperationContext _txnPtr = cc().makeOperationContext(); + OperationContext& _txn = *_txnPtr; private: DBDirectClient _client; diff --git a/src/mongo/dbtests/query_stage_tests.cpp b/src/mongo/dbtests/query_stage_tests.cpp index 3a3ff3be40e..5e3bdbb50fc 100644 --- a/src/mongo/dbtests/query_stage_tests.cpp +++ b/src/mongo/dbtests/query_stage_tests.cpp @@ -26,9 +26,12 @@ * then also delete it in the license file. */ +#include "mongo/platform/basic.h" + #include "mongo/client/dbclientcursor.h" #include "mongo/db/catalog/collection.h" #include "mongo/db/catalog/database.h" +#include "mongo/db/client.h" #include "mongo/db/db_raii.h" #include "mongo/db/dbdirectclient.h" #include "mongo/db/exec/index_scan.h" @@ -36,7 +39,6 @@ #include "mongo/db/json.h" #include "mongo/db/matcher/expression_parser.h" #include "mongo/db/matcher/extensions_callback_disallow_extensions.h" -#include "mongo/db/operation_context_impl.h" #include "mongo/db/query/plan_executor.h" #include "mongo/dbtests/dbtests.h" #include "mongo/stdx/memory.h" @@ -126,7 +128,8 @@ public: } protected: - OperationContextImpl _txn; + const ServiceContext::UniqueOperationContext _txnPtr = cc().makeOperationContext(); + OperationContext& _txn = *_txnPtr; private: DBDirectClient _client; diff --git a/src/mongo/dbtests/query_stage_update.cpp b/src/mongo/dbtests/query_stage_update.cpp index ff232f4cb2a..94632afb4a7 100644 --- a/src/mongo/dbtests/query_stage_update.cpp +++ b/src/mongo/dbtests/query_stage_update.cpp @@ -30,21 +30,22 @@ * This file tests db/exec/update.cpp (UpdateStage). */ +#include "mongo/platform/basic.h" #include "mongo/db/catalog/collection.h" #include "mongo/db/catalog/database.h" +#include "mongo/db/client.h" #include "mongo/db/concurrency/write_conflict_exception.h" #include "mongo/db/db_raii.h" #include "mongo/db/dbdirectclient.h" #include "mongo/db/exec/collection_scan.h" #include "mongo/db/exec/eof.h" -#include "mongo/db/exec/update.h" #include "mongo/db/exec/queued_data_stage.h" +#include "mongo/db/exec/update.h" #include "mongo/db/exec/working_set.h" #include "mongo/db/jsobj.h" #include "mongo/db/json.h" #include "mongo/db/matcher/extensions_callback_disallow_extensions.h" -#include "mongo/db/operation_context_impl.h" #include "mongo/db/ops/update_driver.h" #include "mongo/db/ops/update_lifecycle_impl.h" #include "mongo/db/ops/update_request.h" @@ -169,7 +170,8 @@ public: } protected: - OperationContextImpl _txn; + const ServiceContext::UniqueOperationContext _txnPtr = cc().makeOperationContext(); + OperationContext& _txn = *_txnPtr; private: DBDirectClient _client; diff --git a/src/mongo/dbtests/querytests.cpp b/src/mongo/dbtests/querytests.cpp index e799118ef41..49c11d6dd44 100644 --- a/src/mongo/dbtests/querytests.cpp +++ b/src/mongo/dbtests/querytests.cpp @@ -34,18 +34,18 @@ #include "mongo/client/dbclientcursor.h" #include "mongo/db/catalog/collection.h" +#include "mongo/db/client.h" #include "mongo/db/clientcursor.h" #include "mongo/db/db_raii.h" #include "mongo/db/dbdirectclient.h" #include "mongo/db/dbhelpers.h" -#include "mongo/db/service_context_d.h" -#include "mongo/db/service_context.h" #include "mongo/db/global_timestamp.h" #include "mongo/db/json.h" #include "mongo/db/lasterror.h" -#include "mongo/db/operation_context_impl.h" #include "mongo/db/query/find.h" #include "mongo/db/query/lite_parsed_query.h" +#include "mongo/db/service_context.h" +#include "mongo/db/service_context_d.h" #include "mongo/dbtests/dbtests.h" #include "mongo/util/timer.h" @@ -113,7 +113,8 @@ protected: } - OperationContextImpl _txn; + const ServiceContext::UniqueOperationContext _txnPtr = cc().makeOperationContext(); + OperationContext& _txn = *_txnPtr; ScopedTransaction _scopedXact; Lock::GlobalWrite _lk; OldClientContext _context; @@ -232,7 +233,8 @@ protected: return !_client.getPrevError().getField("err").isNull(); } - OperationContextImpl _txn; + const ServiceContext::UniqueOperationContext _txnPtr = cc().makeOperationContext(); + OperationContext& _txn = *_txnPtr; DBDirectClient _client; }; diff --git a/src/mongo/dbtests/replica_set_monitor_test.cpp b/src/mongo/dbtests/replica_set_monitor_test.cpp index 1e5a7699bea..68d36194b8f 100644 --- a/src/mongo/dbtests/replica_set_monitor_test.cpp +++ b/src/mongo/dbtests/replica_set_monitor_test.cpp @@ -26,6 +26,8 @@ * then also delete it in the license file. */ +#include "mongo/platform/basic.h" + #include "mongo/client/connpool.h" #include "mongo/client/dbclientinterface.h" #include "mongo/client/dbclient_rs.h" diff --git a/src/mongo/dbtests/repltests.cpp b/src/mongo/dbtests/repltests.cpp index 52d30995fd7..0becd7c9fba 100644 --- a/src/mongo/dbtests/repltests.cpp +++ b/src/mongo/dbtests/repltests.cpp @@ -36,11 +36,11 @@ #include "mongo/bson/mutable/document.h" #include "mongo/bson/mutable/mutable_bson_test_utils.h" #include "mongo/db/catalog/collection.h" +#include "mongo/db/client.h" #include "mongo/db/db.h" #include "mongo/db/db_raii.h" #include "mongo/db/dbdirectclient.h" #include "mongo/db/json.h" -#include "mongo/db/operation_context_impl.h" #include "mongo/db/ops/update.h" #include "mongo/db/repl/master_slave.h" #include "mongo/db/repl/oplog.h" @@ -66,7 +66,8 @@ BSONObj f(const char* s) { class Base { protected: - mutable OperationContextImpl _txn; + const ServiceContext::UniqueOperationContext _txnPtr = cc().makeOperationContext(); + OperationContext& _txn = *_txnPtr; mutable DBDirectClient _client; public: diff --git a/src/mongo/dbtests/rollbacktests.cpp b/src/mongo/dbtests/rollbacktests.cpp index 0432b8b30e1..41405295e14 100644 --- a/src/mongo/dbtests/rollbacktests.cpp +++ b/src/mongo/dbtests/rollbacktests.cpp @@ -34,8 +34,8 @@ #include "mongo/db/catalog/database_holder.h" #include "mongo/db/catalog/head_manager.h" #include "mongo/db/catalog/index_create.h" +#include "mongo/db/client.h" #include "mongo/db/db_raii.h" -#include "mongo/db/operation_context_impl.h" #include "mongo/db/record_id.h" #include "mongo/dbtests/dbtests.h" #include "mongo/unittest/unittest.h" @@ -145,7 +145,8 @@ class CreateCollection { public: void run() { string ns = "unittests.rollback_create_collection"; - OperationContextImpl txn; + const ServiceContext::UniqueOperationContext txnPtr = cc().makeOperationContext(); + OperationContext& txn = *txnPtr; NamespaceString nss(ns); dropDatabase(&txn, nss); @@ -174,7 +175,8 @@ class DropCollection { public: void run() { string ns = "unittests.rollback_drop_collection"; - OperationContextImpl txn; + const ServiceContext::UniqueOperationContext txnPtr = cc().makeOperationContext(); + OperationContext& txn = *txnPtr; NamespaceString nss(ns); dropDatabase(&txn, nss); @@ -214,7 +216,8 @@ public: void run() { NamespaceString source("unittests.rollback_rename_collection_src"); NamespaceString target("unittests.rollback_rename_collection_dest"); - OperationContextImpl txn; + const ServiceContext::UniqueOperationContext txnPtr = cc().makeOperationContext(); + OperationContext& txn = *txnPtr; dropDatabase(&txn, source); dropDatabase(&txn, target); @@ -260,7 +263,8 @@ public: void run() { NamespaceString source("unittests.rollback_rename_droptarget_collection_src"); NamespaceString target("unittests.rollback_rename_droptarget_collection_dest"); - OperationContextImpl txn; + const ServiceContext::UniqueOperationContext txnPtr = cc().makeOperationContext(); + OperationContext& txn = *txnPtr; dropDatabase(&txn, source); dropDatabase(&txn, target); @@ -322,7 +326,8 @@ class ReplaceCollection { public: void run() { NamespaceString nss("unittests.rollback_replace_collection"); - OperationContextImpl txn; + const ServiceContext::UniqueOperationContext txnPtr = cc().makeOperationContext(); + OperationContext& txn = *txnPtr; dropDatabase(&txn, nss); ScopedTransaction transaction(&txn, MODE_IX); @@ -372,7 +377,8 @@ class CreateDropCollection { public: void run() { NamespaceString nss("unittests.rollback_create_drop_collection"); - OperationContextImpl txn; + const ServiceContext::UniqueOperationContext txnPtr = cc().makeOperationContext(); + OperationContext& txn = *txnPtr; dropDatabase(&txn, nss); ScopedTransaction transaction(&txn, MODE_IX); @@ -407,7 +413,8 @@ class TruncateCollection { public: void run() { NamespaceString nss("unittests.rollback_truncate_collection"); - OperationContextImpl txn; + const ServiceContext::UniqueOperationContext txnPtr = cc().makeOperationContext(); + OperationContext& txn = *txnPtr; dropDatabase(&txn, nss); ScopedTransaction transaction(&txn, MODE_IX); @@ -456,7 +463,8 @@ class CreateIndex { public: void run() { string ns = "unittests.rollback_create_index"; - OperationContextImpl txn; + const ServiceContext::UniqueOperationContext txnPtr = cc().makeOperationContext(); + OperationContext& txn = *txnPtr; NamespaceString nss(ns); dropDatabase(&txn, nss); createCollection(&txn, nss); @@ -496,7 +504,8 @@ class DropIndex { public: void run() { string ns = "unittests.rollback_drop_index"; - OperationContextImpl txn; + const ServiceContext::UniqueOperationContext txnPtr = cc().makeOperationContext(); + OperationContext& txn = *txnPtr; NamespaceString nss(ns); dropDatabase(&txn, nss); createCollection(&txn, nss); @@ -548,7 +557,8 @@ class CreateDropIndex { public: void run() { string ns = "unittests.rollback_create_drop_index"; - OperationContextImpl txn; + const ServiceContext::UniqueOperationContext txnPtr = cc().makeOperationContext(); + OperationContext& txn = *txnPtr; NamespaceString nss(ns); dropDatabase(&txn, nss); createCollection(&txn, nss); @@ -591,7 +601,8 @@ class SetIndexHead { public: void run() { string ns = "unittests.rollback_set_index_head"; - OperationContextImpl txn; + const ServiceContext::UniqueOperationContext txnPtr = cc().makeOperationContext(); + OperationContext& txn = *txnPtr; NamespaceString nss(ns); dropDatabase(&txn, nss); createCollection(&txn, nss); @@ -653,7 +664,8 @@ class CreateCollectionAndIndexes { public: void run() { string ns = "unittests.rollback_create_collection_and_indexes"; - OperationContextImpl txn; + const ServiceContext::UniqueOperationContext txnPtr = cc().makeOperationContext(); + OperationContext& txn = *txnPtr; NamespaceString nss(ns); dropDatabase(&txn, nss); diff --git a/src/mongo/dbtests/threadedtests.cpp b/src/mongo/dbtests/threadedtests.cpp index 1ad45c337bf..943bfffed15 100644 --- a/src/mongo/dbtests/threadedtests.cpp +++ b/src/mongo/dbtests/threadedtests.cpp @@ -41,16 +41,15 @@ #include "mongo/db/client.h" #include "mongo/db/concurrency/d_concurrency.h" #include "mongo/db/concurrency/lock_state.h" -#include "mongo/db/operation_context_impl.h" #include "mongo/dbtests/dbtests.h" #include "mongo/platform/atomic_word.h" #include "mongo/platform/bits.h" #include "mongo/stdx/functional.h" #include "mongo/stdx/thread.h" #include "mongo/util/concurrency/old_thread_pool.h" +#include "mongo/util/concurrency/old_thread_pool.h" #include "mongo/util/concurrency/rwlock.h" #include "mongo/util/concurrency/synchronization.h" -#include "mongo/util/concurrency/old_thread_pool.h" #include "mongo/util/concurrency/ticketholder.h" #include "mongo/util/log.h" #include "mongo/util/timer.h" @@ -119,7 +118,8 @@ private: virtual void subthread(int tnumber) { Client::initThread("mongomutextest"); - OperationContextImpl txn; + const ServiceContext::UniqueOperationContext txnPtr = cc().makeOperationContext(); + OperationContext& txn = *txnPtr; sleepmillis(0); for (int i = 0; i < N; i++) { diff --git a/src/mongo/dbtests/updatetests.cpp b/src/mongo/dbtests/updatetests.cpp index efd90ce8820..c21b70a551f 100644 --- a/src/mongo/dbtests/updatetests.cpp +++ b/src/mongo/dbtests/updatetests.cpp @@ -35,12 +35,12 @@ #include "mongo/bson/mutable/mutable_bson_test_utils.h" #include "mongo/client/dbclientcursor.h" +#include "mongo/db/client.h" #include "mongo/db/db.h" #include "mongo/db/dbdirectclient.h" #include "mongo/db/json.h" #include "mongo/db/lasterror.h" #include "mongo/db/ops/update.h" -#include "mongo/db/operation_context_impl.h" #include "mongo/dbtests/dbtests.h" namespace UpdateTests { @@ -71,7 +71,8 @@ protected: return !_client.getPrevError().getField("err").isNull(); } - OperationContextImpl _txn; + const ServiceContext::UniqueOperationContext _txnPtr = cc().makeOperationContext(); + OperationContext& _txn = *_txnPtr; DBDirectClient _client; }; diff --git a/src/mongo/dbtests/validate_tests.cpp b/src/mongo/dbtests/validate_tests.cpp index 532a0abbfea..fe82b1c5589 100644 --- a/src/mongo/dbtests/validate_tests.cpp +++ b/src/mongo/dbtests/validate_tests.cpp @@ -26,18 +26,20 @@ * then also delete it in the license file. */ +#include "mongo/platform/basic.h" + #include <cstdint> #include "mongo/db/catalog/collection.h" #include "mongo/db/catalog/index_catalog.h" #include "mongo/db/catalog/index_create.h" +#include "mongo/db/client.h" #include "mongo/db/db_raii.h" #include "mongo/db/dbdirectclient.h" #include "mongo/db/dbhelpers.h" -#include "mongo/db/service_context_d.h" -#include "mongo/db/service_context.h" #include "mongo/db/index/index_descriptor.h" -#include "mongo/db/operation_context_impl.h" +#include "mongo/db/service_context.h" +#include "mongo/db/service_context_d.h" #include "mongo/dbtests/dbtests.h" namespace ValidateTests { @@ -86,7 +88,8 @@ protected: return results.valid; } - OperationContextImpl _txn; + const ServiceContext::UniqueOperationContext _txnPtr = cc().makeOperationContext(); + OperationContext& _txn = *_txnPtr; OldClientWriteContext _ctx; DBDirectClient _client; bool _full; |