diff options
Diffstat (limited to 'src/mongo')
42 files changed, 118 insertions, 46 deletions
diff --git a/src/mongo/client/connection_pool.h b/src/mongo/client/connection_pool.h index 6436bd9bc20..15ca704313f 100644 --- a/src/mongo/client/connection_pool.h +++ b/src/mongo/client/connection_pool.h @@ -194,7 +194,7 @@ private: const int _messagingPortTags; // Mutex guarding members of the connection pool - Mutex _mutex = MONGO_MAKE_LATCH("ConnectionPool::_mutex"); + Mutex _mutex = MONGO_MAKE_LATCH("ClientConnectionPool::_mutex"); // Map from HostAndPort to idle connections. HostConnectionMap _connections; diff --git a/src/mongo/client/connpool.h b/src/mongo/client/connpool.h index 1d39268d588..064ec7c5b5f 100644 --- a/src/mongo/client/connpool.h +++ b/src/mongo/client/connpool.h @@ -38,6 +38,7 @@ #include "mongo/stdx/condition_variable.h" #include "mongo/util/background.h" #include "mongo/util/concurrency/mutex.h" +#include "mongo/util/hierarchical_acquisition.h" #include "mongo/util/time_support.h" namespace mongo { @@ -393,7 +394,8 @@ private: typedef std::map<PoolKey, PoolForHost, poolKeyCompare> PoolMap; // servername -> pool - mutable Mutex _mutex = MONGO_MAKE_LATCH("DBConnectionPool::_mutex"); + mutable Mutex _mutex = + MONGO_MAKE_LATCH(HierarchicalAcquisitionLevel(0), "DBConnectionPool::_mutex"); std::string _name; // The maximum number of connections we'll save in the pool per-host diff --git a/src/mongo/client/dbclient_connection.h b/src/mongo/client/dbclient_connection.h index 72e080665bc..bea9fc74a05 100644 --- a/src/mongo/client/dbclient_connection.h +++ b/src/mongo/client/dbclient_connection.h @@ -53,6 +53,7 @@ #include "mongo/transport/message_compressor_manager.h" #include "mongo/transport/session.h" #include "mongo/transport/transport_layer.h" +#include "mongo/util/hierarchical_acquisition.h" #include "mongo/util/str.h" namespace mongo { @@ -293,7 +294,8 @@ protected: // rebind the handle from the owning thread. The thread that owns this DBClientConnection is // allowed to use the _session without locking the mutex. This mutex also guards writes to // _stayFailed, although reads are allowed outside the mutex. - Mutex _sessionMutex = MONGO_MAKE_LATCH("DBClientConnection::_sessionMutex"); + Mutex _sessionMutex = + MONGO_MAKE_LATCH(HierarchicalAcquisitionLevel(0), "DBClientConnection::_sessionMutex"); transport::SessionHandle _session; boost::optional<Milliseconds> _socketTimeout; transport::Session::TagMask _tagMask = transport::Session::kEmptyTagMask; diff --git a/src/mongo/client/remote_command_retry_scheduler.h b/src/mongo/client/remote_command_retry_scheduler.h index 209e8e171d6..4b6cdd798f4 100644 --- a/src/mongo/client/remote_command_retry_scheduler.h +++ b/src/mongo/client/remote_command_retry_scheduler.h @@ -39,6 +39,7 @@ #include "mongo/executor/task_executor.h" #include "mongo/platform/mutex.h" #include "mongo/stdx/condition_variable.h" +#include "mongo/util/hierarchical_acquisition.h" #include "mongo/util/time_support.h" namespace mongo { @@ -150,7 +151,8 @@ private: Milliseconds _currentUsedMillis{0}; // Protects member data of this scheduler declared after mutex. - mutable Mutex _mutex = MONGO_MAKE_LATCH("RemoteCommandRetryScheduler::_mutex"); + mutable Mutex _mutex = + MONGO_MAKE_LATCH(HierarchicalAcquisitionLevel(2), "RemoteCommandRetryScheduler::_mutex"); mutable stdx::condition_variable _condition; diff --git a/src/mongo/client/replica_set_change_notifier.h b/src/mongo/client/replica_set_change_notifier.h index b79da076c4d..c29aa2b2099 100644 --- a/src/mongo/client/replica_set_change_notifier.h +++ b/src/mongo/client/replica_set_change_notifier.h @@ -38,6 +38,7 @@ #include "mongo/platform/mutex.h" #include "mongo/stdx/unordered_map.h" #include "mongo/util/functional.h" +#include "mongo/util/hierarchical_acquisition.h" namespace mongo { @@ -102,7 +103,8 @@ private: void _addListener(Listener* listener); void _removeListener(Listener* listener); - Mutex _mutex = MONGO_MAKE_LATCH("ReplicaSetChangeNotifier::_mutex"); + Mutex _mutex = + MONGO_MAKE_LATCH(HierarchicalAcquisitionLevel(0), "ReplicaSetChangeNotifier::_mutex"); std::vector<Listener*> _listeners; stdx::unordered_map<Key, State> _replicaSetStates; }; diff --git a/src/mongo/client/replica_set_monitor_manager.h b/src/mongo/client/replica_set_monitor_manager.h index 04ef76b08e4..c464551145f 100644 --- a/src/mongo/client/replica_set_monitor_manager.h +++ b/src/mongo/client/replica_set_monitor_manager.h @@ -35,6 +35,7 @@ #include "mongo/client/replica_set_change_notifier.h" #include "mongo/executor/task_executor.h" #include "mongo/platform/mutex.h" +#include "mongo/util/hierarchical_acquisition.h" #include "mongo/util/string_map.h" namespace mongo { @@ -104,7 +105,8 @@ private: using ReplicaSetMonitorsMap = StringMap<std::weak_ptr<ReplicaSetMonitor>>; // Protects access to the replica set monitors - mutable Mutex _mutex = MONGO_MAKE_LATCH("ReplicaSetMonitorManager::_mutex"); + mutable Mutex _mutex = + MONGO_MAKE_LATCH(HierarchicalAcquisitionLevel(0), "ReplicaSetMonitorManager::_mutex"); // Executor for monitoring replica sets. std::unique_ptr<executor::TaskExecutor> _taskExecutor; diff --git a/src/mongo/db/logical_session_cache_impl.h b/src/mongo/db/logical_session_cache_impl.h index afea7052761..ef13703005e 100644 --- a/src/mongo/db/logical_session_cache_impl.h +++ b/src/mongo/db/logical_session_cache_impl.h @@ -34,6 +34,7 @@ #include "mongo/db/sessions_collection.h" #include "mongo/util/concurrency/with_lock.h" #include "mongo/util/functional.h" +#include "mongo/util/hierarchical_acquisition.h" namespace mongo { @@ -106,7 +107,8 @@ private: const std::shared_ptr<SessionsCollection> _sessionsColl; const ReapSessionsOlderThanFn _reapSessionsOlderThanFn; - mutable Mutex _mutex = MONGO_MAKE_LATCH("LogicalSessionCacheImpl::_mutex"); + mutable Mutex _mutex = + MONGO_MAKE_LATCH(HierarchicalAcquisitionLevel(0), "LogicalSessionCacheImpl::_mutex"); LogicalSessionIdMap<LogicalSessionRecord> _activeSessions; diff --git a/src/mongo/db/periodic_runner_job_abort_expired_transactions.h b/src/mongo/db/periodic_runner_job_abort_expired_transactions.h index f372db87226..b2831c19130 100644 --- a/src/mongo/db/periodic_runner_job_abort_expired_transactions.h +++ b/src/mongo/db/periodic_runner_job_abort_expired_transactions.h @@ -33,6 +33,7 @@ #include "mongo/db/service_context.h" #include "mongo/platform/mutex.h" +#include "mongo/util/hierarchical_acquisition.h" #include "mongo/util/periodic_runner.h" namespace mongo { @@ -55,7 +56,8 @@ private: inline static const auto _serviceDecoration = ServiceContext::declareDecoration<PeriodicThreadToAbortExpiredTransactions>(); - mutable Mutex _mutex = MONGO_MAKE_LATCH("PeriodicThreadToAbortExpiredTransactions::_mutex"); + mutable Mutex _mutex = MONGO_MAKE_LATCH(HierarchicalAcquisitionLevel(1), + "PeriodicThreadToAbortExpiredTransactions::_mutex"); std::shared_ptr<PeriodicJobAnchor> _anchor; }; diff --git a/src/mongo/db/periodic_runner_job_decrease_snapshot_cache_pressure.h b/src/mongo/db/periodic_runner_job_decrease_snapshot_cache_pressure.h index 1705d2d01d1..7a4f5fd9c30 100644 --- a/src/mongo/db/periodic_runner_job_decrease_snapshot_cache_pressure.h +++ b/src/mongo/db/periodic_runner_job_decrease_snapshot_cache_pressure.h @@ -33,6 +33,7 @@ #include "mongo/db/service_context.h" #include "mongo/platform/mutex.h" +#include "mongo/util/hierarchical_acquisition.h" #include "mongo/util/periodic_runner.h" namespace mongo { @@ -60,7 +61,8 @@ private: ServiceContext::declareDecoration<PeriodicThreadToDecreaseSnapshotHistoryCachePressure>(); mutable Mutex _mutex = - MONGO_MAKE_LATCH("PeriodicThreadToDecreaseSnapshotHistoryCachePressure::_mutex"); + MONGO_MAKE_LATCH(HierarchicalAcquisitionLevel(1), + "PeriodicThreadToDecreaseSnapshotHistoryCachePressure::_mutex"); std::shared_ptr<PeriodicJobAnchor> _anchor; }; diff --git a/src/mongo/db/service_context.h b/src/mongo/db/service_context.h index 7a9270061d2..a00e69dc604 100644 --- a/src/mongo/db/service_context.h +++ b/src/mongo/db/service_context.h @@ -47,6 +47,7 @@ #include "mongo/util/clock_source.h" #include "mongo/util/concurrency/with_lock.h" #include "mongo/util/decorable.h" +#include "mongo/util/hierarchical_acquisition.h" #include "mongo/util/periodic_runner.h" #include "mongo/util/tick_source.h" @@ -540,7 +541,7 @@ private: std::unique_ptr<ClientObserver> _observer; }; - Mutex _mutex = MONGO_MAKE_LATCH("ServiceContext::_mutex"); + Mutex _mutex = MONGO_MAKE_LATCH(HierarchicalAcquisitionLevel(2), "ServiceContext::_mutex"); /** * The periodic runner. diff --git a/src/mongo/db/service_liaison_mongod.h b/src/mongo/db/service_liaison_mongod.h index 3cf8864b5eb..574e5d98ebb 100644 --- a/src/mongo/db/service_liaison_mongod.h +++ b/src/mongo/db/service_liaison_mongod.h @@ -32,6 +32,7 @@ #include "mongo/db/logical_session_id.h" #include "mongo/db/operation_context.h" #include "mongo/db/service_liaison.h" +#include "mongo/util/hierarchical_acquisition.h" #include "mongo/util/periodic_runner.h" #include "mongo/util/time_support.h" @@ -69,7 +70,8 @@ protected: */ ServiceContext* _context() override; - Mutex _mutex = MONGO_MAKE_LATCH("ServiceLiaisonMongod::_mutex"); + Mutex _mutex = + MONGO_MAKE_LATCH(HierarchicalAcquisitionLevel(0), "ServiceLiaisonMongod::_mutex"); std::vector<PeriodicJobAnchor> _jobs; }; diff --git a/src/mongo/db/service_liaison_mongos.h b/src/mongo/db/service_liaison_mongos.h index 22fc7032d73..4b9488d2b2d 100644 --- a/src/mongo/db/service_liaison_mongos.h +++ b/src/mongo/db/service_liaison_mongos.h @@ -32,6 +32,7 @@ #include "mongo/db/logical_session_id.h" #include "mongo/db/operation_context.h" #include "mongo/db/service_liaison.h" +#include "mongo/util/hierarchical_acquisition.h" #include "mongo/util/periodic_runner.h" #include "mongo/util/time_support.h" @@ -69,7 +70,8 @@ protected: */ ServiceContext* _context() override; - Mutex _mutex = MONGO_MAKE_LATCH("ServiceLiaisonMongos::_mutex"); + Mutex _mutex = + MONGO_MAKE_LATCH(HierarchicalAcquisitionLevel(0), "ServiceLiaisonMongos::_mutex"); std::vector<PeriodicJobAnchor> _jobs; }; diff --git a/src/mongo/db/session_catalog.h b/src/mongo/db/session_catalog.h index 025fab44676..6841d85a6f6 100644 --- a/src/mongo/db/session_catalog.h +++ b/src/mongo/db/session_catalog.h @@ -41,6 +41,7 @@ #include "mongo/stdx/condition_variable.h" #include "mongo/stdx/unordered_map.h" #include "mongo/util/concurrency/with_lock.h" +#include "mongo/util/hierarchical_acquisition.h" namespace mongo { @@ -153,7 +154,8 @@ private: void _releaseSession(SessionRuntimeInfo* sri, boost::optional<KillToken> killToken); // Protects the state below - mutable Mutex _mutex = MONGO_MAKE_LATCH("SessionCatalog::_mutex"); + mutable Mutex _mutex = + MONGO_MAKE_LATCH(HierarchicalAcquisitionLevel(0), "SessionCatalog::_mutex"); // Owns the Session objects for all current Sessions. SessionRuntimeInfoMap _sessions; diff --git a/src/mongo/db/session_killer.h b/src/mongo/db/session_killer.h index 231fd01dc12..8b5c14bd2ba 100644 --- a/src/mongo/db/session_killer.h +++ b/src/mongo/db/session_killer.h @@ -41,6 +41,7 @@ #include "mongo/stdx/condition_variable.h" #include "mongo/stdx/thread.h" #include "mongo/stdx/unordered_set.h" +#include "mongo/util/hierarchical_acquisition.h" #include "mongo/util/net/hostandport.h" namespace mongo { @@ -131,7 +132,7 @@ private: stdx::thread _thread; - Mutex _mutex = MONGO_MAKE_LATCH("SessionKiller::_mutex"); + Mutex _mutex = MONGO_MAKE_LATCH(HierarchicalAcquisitionLevel(0), "SessionKiller::_mutex"); stdx::condition_variable _callerCV; stdx::condition_variable _killerCV; diff --git a/src/mongo/executor/connection_pool.cpp b/src/mongo/executor/connection_pool.cpp index a0a4c9f0a7c..42ff763018f 100644 --- a/src/mongo/executor/connection_pool.cpp +++ b/src/mongo/executor/connection_pool.cpp @@ -43,6 +43,7 @@ #include "mongo/executor/remote_command_request.h" #include "mongo/util/assert_util.h" #include "mongo/util/destructor_guard.h" +#include "mongo/util/hierarchical_acquisition.h" #include "mongo/util/log.h" #include "mongo/util/lru_cache.h" #include "mongo/util/scopeguard.h" @@ -189,7 +190,7 @@ protected: size_t target = 0; }; - Mutex _mutex = MONGO_MAKE_LATCH("LimitController::_mutex"); + Mutex _mutex = MONGO_MAKE_LATCH(HierarchicalAcquisitionLevel(0), "LimitController::_mutex"); stdx::unordered_map<PoolId, PoolData> _poolData; }; diff --git a/src/mongo/executor/connection_pool.h b/src/mongo/executor/connection_pool.h index f46c3c23dfa..f5f8629a8c2 100644 --- a/src/mongo/executor/connection_pool.h +++ b/src/mongo/executor/connection_pool.h @@ -41,6 +41,7 @@ #include "mongo/transport/transport_layer.h" #include "mongo/util/duration.h" #include "mongo/util/future.h" +#include "mongo/util/hierarchical_acquisition.h" #include "mongo/util/net/hostandport.h" #include "mongo/util/out_of_line_executor.h" #include "mongo/util/time_support.h" @@ -255,7 +256,8 @@ private: std::shared_ptr<ControllerInterface> _controller; // The global mutex for specific pool access and the generation counter - mutable Mutex _mutex = MONGO_MAKE_LATCH("ConnectionPool::_mutex"); + mutable Mutex _mutex = + MONGO_MAKE_LATCH(HierarchicalAcquisitionLevel(1), "ExecutorConnectionPool::_mutex"); PoolId _nextPoolId = 0; stdx::unordered_map<HostAndPort, std::shared_ptr<SpecificPool>> _pools; diff --git a/src/mongo/executor/connection_pool_tl.h b/src/mongo/executor/connection_pool_tl.h index f5bf54ff081..b765f9ddd15 100644 --- a/src/mongo/executor/connection_pool_tl.h +++ b/src/mongo/executor/connection_pool_tl.h @@ -36,6 +36,7 @@ #include "mongo/executor/network_connection_hook.h" #include "mongo/executor/network_interface.h" #include "mongo/util/future.h" +#include "mongo/util/hierarchical_acquisition.h" namespace mongo { namespace executor { @@ -79,7 +80,8 @@ private: std::unique_ptr<NetworkConnectionHook> _onConnectHook; const ConnectionPool::Options _connPoolOptions; - mutable Mutex _mutex = MONGO_MAKE_LATCH("TLTypeFactory::_mutex"); + mutable Mutex _mutex = + MONGO_MAKE_LATCH(HierarchicalAcquisitionLevel(0), "TLTypeFactory::_mutex"); AtomicWord<bool> _inShutdown{false}; stdx::unordered_set<Type*> _collars; }; diff --git a/src/mongo/executor/egress_tag_closer_manager.h b/src/mongo/executor/egress_tag_closer_manager.h index 91d996ee3dc..e2243ae1c6c 100644 --- a/src/mongo/executor/egress_tag_closer_manager.h +++ b/src/mongo/executor/egress_tag_closer_manager.h @@ -36,6 +36,7 @@ #include "mongo/platform/mutex.h" #include "mongo/stdx/unordered_set.h" #include "mongo/transport/session.h" +#include "mongo/util/hierarchical_acquisition.h" #include "mongo/util/net/hostandport.h" namespace mongo { @@ -65,7 +66,8 @@ public: const std::function<transport::Session::TagMask(transport::Session::TagMask)>& mutateFunc); private: - Mutex _mutex = MONGO_MAKE_LATCH("EgressTagCloserManager::_mutex"); + Mutex _mutex = + MONGO_MAKE_LATCH(HierarchicalAcquisitionLevel(2), "EgressTagCloserManager::_mutex"); stdx::unordered_set<EgressTagCloser*> _egressTagClosers; }; diff --git a/src/mongo/executor/network_interface_thread_pool.h b/src/mongo/executor/network_interface_thread_pool.h index 3a295b26a5b..6cf058cac50 100644 --- a/src/mongo/executor/network_interface_thread_pool.h +++ b/src/mongo/executor/network_interface_thread_pool.h @@ -35,6 +35,7 @@ #include "mongo/platform/mutex.h" #include "mongo/stdx/condition_variable.h" #include "mongo/util/concurrency/thread_pool_interface.h" +#include "mongo/util/hierarchical_acquisition.h" namespace mongo { namespace executor { @@ -67,7 +68,8 @@ private: NetworkInterface* const _net; // Protects all of the pool state below - Mutex _mutex = MONGO_MAKE_LATCH("NetworkInterfaceThreadPool::_mutex"); + Mutex _mutex = + MONGO_MAKE_LATCH(HierarchicalAcquisitionLevel(0), "NetworkInterfaceThreadPool::_mutex"); stdx::condition_variable _joiningCondition; std::vector<Task> _tasks; bool _started = false; diff --git a/src/mongo/executor/network_interface_tl.h b/src/mongo/executor/network_interface_tl.h index ee27fdd410f..80e510a015f 100644 --- a/src/mongo/executor/network_interface_tl.h +++ b/src/mongo/executor/network_interface_tl.h @@ -40,6 +40,7 @@ #include "mongo/stdx/unordered_map.h" #include "mongo/transport/baton.h" #include "mongo/transport/transport_layer.h" +#include "mongo/util/hierarchical_acquisition.h" #include "mongo/util/strong_weak_finish_line.h" namespace mongo { @@ -147,7 +148,8 @@ private: std::unique_ptr<transport::TransportLayer> _ownedTransportLayer; transport::ReactorHandle _reactor; - mutable Mutex _mutex = MONGO_MAKE_LATCH("NetworkInterfaceTL::_mutex"); + mutable Mutex _mutex = + MONGO_MAKE_LATCH(HierarchicalAcquisitionLevel(3), "NetworkInterfaceTL::_mutex"); ConnectionPool::Options _connPoolOpts; std::unique_ptr<NetworkConnectionHook> _onConnectHook; std::shared_ptr<ConnectionPool> _pool; @@ -165,7 +167,8 @@ private: AtomicWord<State> _state; stdx::thread _ioThread; - Mutex _inProgressMutex = MONGO_MAKE_LATCH("NetworkInterfaceTL::_inProgressMutex"); + Mutex _inProgressMutex = + MONGO_MAKE_LATCH(HierarchicalAcquisitionLevel(0), "NetworkInterfaceTL::_inProgressMutex"); stdx::unordered_map<TaskExecutor::CallbackHandle, std::weak_ptr<CommandState>> _inProgress; stdx::unordered_map<TaskExecutor::CallbackHandle, std::shared_ptr<AlarmState>> _inProgressAlarms; diff --git a/src/mongo/executor/thread_pool_task_executor.h b/src/mongo/executor/thread_pool_task_executor.h index c543e4fb0c8..1ac9c385a98 100644 --- a/src/mongo/executor/thread_pool_task_executor.h +++ b/src/mongo/executor/thread_pool_task_executor.h @@ -38,6 +38,7 @@ #include "mongo/stdx/thread.h" #include "mongo/transport/baton.h" #include "mongo/util/fail_point.h" +#include "mongo/util/hierarchical_acquisition.h" namespace mongo { @@ -188,7 +189,8 @@ private: std::shared_ptr<ThreadPoolInterface> _pool; // Mutex guarding all remaining fields. - mutable Mutex _mutex = MONGO_MAKE_LATCH("ThreadPoolTaskExecutor::_mutex"); + mutable Mutex _mutex = + MONGO_MAKE_LATCH(HierarchicalAcquisitionLevel(1), "ThreadPoolTaskExecutor::_mutex"); // Queue containing all items currently scheduled into the thread pool but not yet completed. WorkQueue _poolInProgressQueue; diff --git a/src/mongo/idl/mutable_observer_registry.h b/src/mongo/idl/mutable_observer_registry.h index 2dfc0241f34..d8d26803fc2 100644 --- a/src/mongo/idl/mutable_observer_registry.h +++ b/src/mongo/idl/mutable_observer_registry.h @@ -34,6 +34,7 @@ #include "mongo/base/status.h" #include "mongo/platform/mutex.h" #include "mongo/util/functional.h" +#include "mongo/util/hierarchical_acquisition.h" namespace mongo { @@ -66,7 +67,8 @@ public: } private: - Mutex _mutex = MONGO_MAKE_LATCH("MutableObserverRegistry::_mutex"); + Mutex _mutex = + MONGO_MAKE_LATCH(HierarchicalAcquisitionLevel(0), "MutableObserverRegistry::_mutex"); std::vector<unique_function<void(const T&)>> _registry; }; diff --git a/src/mongo/s/client/rs_local_client.h b/src/mongo/s/client/rs_local_client.h index 7dabd19d454..233732b5c8e 100644 --- a/src/mongo/s/client/rs_local_client.h +++ b/src/mongo/s/client/rs_local_client.h @@ -32,6 +32,7 @@ #include "mongo/db/repl/optime.h" #include "mongo/platform/mutex.h" #include "mongo/s/client/shard.h" +#include "mongo/util/hierarchical_acquisition.h" namespace mongo { @@ -86,7 +87,7 @@ private: repl::OpTime _getLastOpTime(); // Guards _lastOpTime below. - Mutex _mutex = MONGO_MAKE_LATCH("RSLocalClient::_mutex"); + Mutex _mutex = MONGO_MAKE_LATCH(HierarchicalAcquisitionLevel(0), "RSLocalClient::_mutex"); // Stores the optime that was generated by the last operation to perform a write that was run // through _runCommand. Used in _exhaustiveFindOnConfig for waiting for that optime to be diff --git a/src/mongo/s/client/shard_connection.cpp b/src/mongo/s/client/shard_connection.cpp index 1e56594331d..b78e4aefeeb 100644 --- a/src/mongo/s/client/shard_connection.cpp +++ b/src/mongo/s/client/shard_connection.cpp @@ -48,6 +48,7 @@ #include "mongo/s/transaction_router.h" #include "mongo/util/concurrency/spin_lock.h" #include "mongo/util/exit.h" +#include "mongo/util/hierarchical_acquisition.h" #include "mongo/util/log.h" #include "mongo/util/stacktrace.h" @@ -75,7 +76,8 @@ public: void appendInfo(BSONObjBuilder* b) const; private: - mutable Mutex _mutex = MONGO_MAKE_LATCH("ActiveClientConnections::_mutex"); + mutable Mutex _mutex = + MONGO_MAKE_LATCH(HierarchicalAcquisitionLevel(0), "ActiveClientConnections::_mutex"); std::set<const ClientConnections*> _clientConnections; } activeClientConnections; diff --git a/src/mongo/s/client/version_manager.cpp b/src/mongo/s/client/version_manager.cpp index 27907950ac4..8072767f7c2 100644 --- a/src/mongo/s/client/version_manager.cpp +++ b/src/mongo/s/client/version_manager.cpp @@ -44,6 +44,7 @@ #include "mongo/s/request_types/set_shard_version_request.h" #include "mongo/s/stale_exception.h" #include "mongo/s/transaction_router.h" +#include "mongo/util/hierarchical_acquisition.h" #include "mongo/util/log.h" namespace mongo { @@ -96,7 +97,8 @@ public: private: // protects _map - Mutex _mutex = MONGO_MAKE_LATCH("ConnectionShardStatus::_mutex"); + Mutex _mutex = + MONGO_MAKE_LATCH(HierarchicalAcquisitionLevel(0), "ConnectionShardStatus::_mutex"); // a map from a connection into ChunkManager's sequence number for each namespace typedef map<unsigned long long, map<string, unsigned long long>> SequenceMap; diff --git a/src/mongo/s/cluster_identity_loader.h b/src/mongo/s/cluster_identity_loader.h index df2ed8b40d6..693c62483ad 100644 --- a/src/mongo/s/cluster_identity_loader.h +++ b/src/mongo/s/cluster_identity_loader.h @@ -35,6 +35,7 @@ #include "mongo/db/repl/read_concern_args.h" #include "mongo/platform/mutex.h" #include "mongo/stdx/condition_variable.h" +#include "mongo/util/hierarchical_acquisition.h" namespace mongo { @@ -94,7 +95,8 @@ private: StatusWith<OID> _fetchClusterIdFromConfig(OperationContext* opCtx, const repl::ReadConcernLevel& readConcernLevel); - Mutex _mutex = MONGO_MAKE_LATCH("ClusterIdentityLoader::_mutex"); + Mutex _mutex = + MONGO_MAKE_LATCH(HierarchicalAcquisitionLevel(0), "ClusterIdentityLoader::_mutex"); stdx::condition_variable _inReloadCV; // Used to ensure that only one thread at a time attempts to reload the cluster ID from the diff --git a/src/mongo/s/grid.h b/src/mongo/s/grid.h index 92b7a761f97..0bd14b9c5cf 100644 --- a/src/mongo/s/grid.h +++ b/src/mongo/s/grid.h @@ -37,6 +37,7 @@ #include "mongo/s/catalog/sharding_catalog_client.h" #include "mongo/s/catalog_cache.h" #include "mongo/s/client/shard_registry.h" +#include "mongo/util/hierarchical_acquisition.h" namespace mongo { @@ -192,7 +193,7 @@ private: AtomicWord<bool> _shardingInitialized{false}; // Protects _configOpTime. - mutable Mutex _mutex = MONGO_MAKE_LATCH("Grid::_mutex"); + mutable Mutex _mutex = MONGO_MAKE_LATCH(HierarchicalAcquisitionLevel(0), "Grid::_mutex"); // Last known highest opTime from the config server that should be used when doing reads. // This value is updated any time a shard or mongos talks to a config server or a shard. diff --git a/src/mongo/s/router_transactions_metrics.h b/src/mongo/s/router_transactions_metrics.h index 5c52a8e20d0..f7f6b157735 100644 --- a/src/mongo/s/router_transactions_metrics.h +++ b/src/mongo/s/router_transactions_metrics.h @@ -33,6 +33,7 @@ #include "mongo/db/service_context.h" #include "mongo/s/router_transactions_stats_gen.h" #include "mongo/s/transaction_router.h" +#include "mongo/util/hierarchical_acquisition.h" namespace mongo { @@ -147,7 +148,8 @@ private: CommitStats _recoverWithTokenCommitStats; // Mutual exclusion for _abortCauseMap - Mutex _abortCauseMutex = MONGO_MAKE_LATCH("RouterTransactionsMetrics::_abortCauseMutex"); + Mutex _abortCauseMutex = MONGO_MAKE_LATCH(HierarchicalAcquisitionLevel(0), + "RouterTransactionsMetrics::_abortCauseMutex"); // Map tracking the total number of each abort cause for any multi-statement transaction that // was aborted through this router. diff --git a/src/mongo/transport/baton_asio_linux.h b/src/mongo/transport/baton_asio_linux.h index 930cf52c67d..96cf7019523 100644 --- a/src/mongo/transport/baton_asio_linux.h +++ b/src/mongo/transport/baton_asio_linux.h @@ -44,6 +44,7 @@ #include "mongo/transport/session_asio.h" #include "mongo/util/errno_util.h" #include "mongo/util/future.h" +#include "mongo/util/hierarchical_acquisition.h" #include "mongo/util/time_support.h" namespace mongo { @@ -456,7 +457,7 @@ private: return EventFDHolder::getForClient(_opCtx->getClient()); } - Mutex _mutex = MONGO_MAKE_LATCH("BatonASIO::_mutex"); + Mutex _mutex = MONGO_MAKE_LATCH(HierarchicalAcquisitionLevel(0), "BatonASIO::_mutex"); OperationContext* _opCtx; diff --git a/src/mongo/transport/service_entry_point_impl.h b/src/mongo/transport/service_entry_point_impl.h index 58fcb6cf998..38c1319657a 100644 --- a/src/mongo/transport/service_entry_point_impl.h +++ b/src/mongo/transport/service_entry_point_impl.h @@ -38,6 +38,7 @@ #include "mongo/transport/service_entry_point.h" #include "mongo/transport/service_executor_reserved.h" #include "mongo/transport/service_state_machine.h" +#include "mongo/util/hierarchical_acquisition.h" #include "mongo/util/net/cidr.h" namespace mongo { @@ -81,7 +82,8 @@ private: ServiceContext* const _svcCtx; AtomicWord<std::size_t> _nWorkers; - mutable Mutex _sessionsMutex = MONGO_MAKE_LATCH("ServiceEntryPointImpl::_sessionsMutex"); + mutable Mutex _sessionsMutex = + MONGO_MAKE_LATCH(HierarchicalAcquisitionLevel(0), "ServiceEntryPointImpl::_sessionsMutex"); stdx::condition_variable _shutdownCondition; SSMList _sessions; diff --git a/src/mongo/transport/service_executor_synchronous.h b/src/mongo/transport/service_executor_synchronous.h index 1f0e2f6dd33..5f3aac7ccfa 100644 --- a/src/mongo/transport/service_executor_synchronous.h +++ b/src/mongo/transport/service_executor_synchronous.h @@ -37,6 +37,7 @@ #include "mongo/stdx/condition_variable.h" #include "mongo/transport/service_executor.h" #include "mongo/transport/service_executor_task_names.h" +#include "mongo/util/hierarchical_acquisition.h" namespace mongo { namespace transport { @@ -66,7 +67,8 @@ private: AtomicWord<bool> _stillRunning{false}; - mutable Mutex _shutdownMutex = MONGO_MAKE_LATCH("ServiceExecutorSynchronous::_shutdownMutex"); + mutable Mutex _shutdownMutex = MONGO_MAKE_LATCH(HierarchicalAcquisitionLevel(0), + "ServiceExecutorSynchronous::_shutdownMutex"); stdx::condition_variable _shutdownCondition; AtomicWord<size_t> _numRunningWorkerThreads{0}; diff --git a/src/mongo/transport/transport_layer_asio.cpp b/src/mongo/transport/transport_layer_asio.cpp index c4935af090e..8dc5924acd8 100644 --- a/src/mongo/transport/transport_layer_asio.cpp +++ b/src/mongo/transport/transport_layer_asio.cpp @@ -44,6 +44,7 @@ #include "mongo/db/service_context.h" #include "mongo/transport/asio_utils.h" #include "mongo/transport/service_entry_point.h" +#include "mongo/util/hierarchical_acquisition.h" #include "mongo/util/log.h" #include "mongo/util/net/hostandport.h" #include "mongo/util/net/sockaddr.h" @@ -530,7 +531,7 @@ Future<SessionHandle> TransportLayerASIO::asyncConnect(HostAndPort peer, AtomicWord<bool> done{false}; Promise<SessionHandle> promise; - Mutex mutex = MONGO_MAKE_LATCH("AsyncConnectState::mutex"); + Mutex mutex = MONGO_MAKE_LATCH(HierarchicalAcquisitionLevel(0), "AsyncConnectState::mutex"); GenericSocket socket; ASIOReactorTimer timeoutTimer; WrappedResolver resolver; diff --git a/src/mongo/transport/transport_layer_asio.h b/src/mongo/transport/transport_layer_asio.h index 77a8e5e555b..0c4c7e062e5 100644 --- a/src/mongo/transport/transport_layer_asio.h +++ b/src/mongo/transport/transport_layer_asio.h @@ -42,6 +42,7 @@ #include "mongo/transport/transport_layer.h" #include "mongo/transport/transport_mode.h" #include "mongo/util/fail_point.h" +#include "mongo/util/hierarchical_acquisition.h" #include "mongo/util/net/hostandport.h" #include "mongo/util/net/ssl_options.h" #include "mongo/util/net/ssl_types.h" @@ -160,7 +161,7 @@ private: SSLParams::SSLModes _sslMode() const; #endif - Mutex _mutex = MONGO_MAKE_LATCH("TransportLayerASIO::_mutex"); + Mutex _mutex = MONGO_MAKE_LATCH(HierarchicalAcquisitionLevel(0), "TransportLayerASIO::_mutex"); // There are three reactors that are used by TransportLayerASIO. The _ingressReactor contains // all the accepted sockets and all ingress networking activity. The _acceptorReactor contains diff --git a/src/mongo/transport/transport_layer_manager.h b/src/mongo/transport/transport_layer_manager.h index 3bc0e6ba5c6..8da53951276 100644 --- a/src/mongo/transport/transport_layer_manager.h +++ b/src/mongo/transport/transport_layer_manager.h @@ -35,6 +35,7 @@ #include "mongo/platform/mutex.h" #include "mongo/transport/session.h" #include "mongo/transport/transport_layer.h" +#include "mongo/util/hierarchical_acquisition.h" #include "mongo/util/time_support.h" namespace mongo { @@ -101,7 +102,8 @@ private: template <typename Callable> void _foreach(Callable&& cb) const; - mutable Mutex _tlsMutex = MONGO_MAKE_LATCH("TransportLayerManager::_tlsMutex"); + mutable Mutex _tlsMutex = + MONGO_MAKE_LATCH(HierarchicalAcquisitionLevel(1), "TransportLayerManager::_tlsMutex"); std::vector<std::unique_ptr<TransportLayer>> _tls; }; diff --git a/src/mongo/util/background.cpp b/src/mongo/util/background.cpp index e0bda9a55d9..9dff4675fc7 100644 --- a/src/mongo/util/background.cpp +++ b/src/mongo/util/background.cpp @@ -44,6 +44,7 @@ #include "mongo/util/concurrency/spin_lock.h" #include "mongo/util/concurrency/thread_name.h" #include "mongo/util/debug_util.h" +#include "mongo/util/hierarchical_acquisition.h" #include "mongo/util/log.h" #include "mongo/util/str.h" #include "mongo/util/timer.h" @@ -80,7 +81,7 @@ private: void _runTask(PeriodicTask* task); // _mutex protects the _shutdownRequested flag and the _tasks vector. - Mutex _mutex = MONGO_MAKE_LATCH("PeriodicTaskRunner::_mutex"); + Mutex _mutex = MONGO_MAKE_LATCH(HierarchicalAcquisitionLevel(0), "PeriodicTaskRunner::_mutex"); // The condition variable is used to sleep for the interval between task // executions, and is notified when the _shutdownRequested flag is toggled. diff --git a/src/mongo/util/concurrency/notification.h b/src/mongo/util/concurrency/notification.h index 379b6e10d9a..359a22a3258 100644 --- a/src/mongo/util/concurrency/notification.h +++ b/src/mongo/util/concurrency/notification.h @@ -36,6 +36,7 @@ #include "mongo/stdx/condition_variable.h" #include "mongo/util/assert_util.h" #include "mongo/util/duration.h" +#include "mongo/util/hierarchical_acquisition.h" #include "mongo/util/time_support.h" namespace mongo { @@ -110,7 +111,8 @@ public: } private: - mutable Mutex _mutex = MONGO_MAKE_LATCH("Notification::_mutex"); + mutable Mutex _mutex = + MONGO_MAKE_LATCH(HierarchicalAcquisitionLevel(0), "Notification::_mutex"); stdx::condition_variable _condVar; // Protected by mutex and only moves from not-set to set once diff --git a/src/mongo/util/concurrency/thread_pool.h b/src/mongo/util/concurrency/thread_pool.h index 91981d1c808..c178f1d1a8d 100644 --- a/src/mongo/util/concurrency/thread_pool.h +++ b/src/mongo/util/concurrency/thread_pool.h @@ -38,6 +38,7 @@ #include "mongo/stdx/condition_variable.h" #include "mongo/stdx/thread.h" #include "mongo/util/concurrency/thread_pool_interface.h" +#include "mongo/util/hierarchical_acquisition.h" #include "mongo/util/time_support.h" namespace mongo { @@ -213,7 +214,7 @@ private: const Options _options; // Mutex guarding all non-const member variables. - mutable Mutex _mutex = MONGO_MAKE_LATCH("ThreadPool::_mutex"); + mutable Mutex _mutex = MONGO_MAKE_LATCH(HierarchicalAcquisitionLevel(0), "ThreadPool::_mutex"); // This variable represents the lifecycle state of the pool. // diff --git a/src/mongo/util/concurrency/ticketholder.h b/src/mongo/util/concurrency/ticketholder.h index af9baa934ed..ad7b2e92a29 100644 --- a/src/mongo/util/concurrency/ticketholder.h +++ b/src/mongo/util/concurrency/ticketholder.h @@ -36,6 +36,7 @@ #include "mongo/platform/mutex.h" #include "mongo/stdx/condition_variable.h" #include "mongo/util/concurrency/mutex.h" +#include "mongo/util/hierarchical_acquisition.h" #include "mongo/util/time_support.h" namespace mongo { @@ -87,13 +88,14 @@ private: // You can read _outof without a lock, but have to hold _resizeMutex to change. AtomicWord<int> _outof; - Mutex _resizeMutex = MONGO_MAKE_LATCH("TicketHolder::_resizeMutex"); + Mutex _resizeMutex = + MONGO_MAKE_LATCH(HierarchicalAcquisitionLevel(0), "TicketHolder::_resizeMutex"); #else bool _tryAcquire(); AtomicWord<int> _outof; int _num; - Mutex _mutex = MONGO_MAKE_LATCH("TicketHolder::_mutex"); + Mutex _mutex = MONGO_MAKE_LATCH(HierarchicalAcquisitionLevel(0), "TicketHolder::_mutex"); stdx::condition_variable _newTicket; #endif }; diff --git a/src/mongo/util/diagnostic_info.cpp b/src/mongo/util/diagnostic_info.cpp index 869dd13babe..edf19a279df 100644 --- a/src/mongo/util/diagnostic_info.cpp +++ b/src/mongo/util/diagnostic_info.cpp @@ -42,6 +42,7 @@ #include "mongo/db/client.h" #include "mongo/platform/mutex.h" #include "mongo/util/clock_source.h" +#include "mongo/util/hierarchical_acquisition.h" #include "mongo/util/interruptible.h" #include "mongo/util/log.h" @@ -70,7 +71,7 @@ private: bool isContended = false; boost::optional<stdx::thread> thread{boost::none}; - Mutex mutex = MONGO_MAKE_LATCH(kBlockedOpMutexName); + Mutex mutex = MONGO_MAKE_LATCH(HierarchicalAcquisitionLevel(3), kBlockedOpMutexName); }; LatchState _latchState; @@ -79,7 +80,8 @@ private: boost::optional<stdx::thread> thread{boost::none}; stdx::condition_variable cv; - Mutex mutex = MONGO_MAKE_LATCH(kBlockedOpInterruptibleName); + Mutex mutex = + MONGO_MAKE_LATCH(HierarchicalAcquisitionLevel(0), kBlockedOpInterruptibleName); bool isDone = false; }; InterruptibleState _interruptibleState; diff --git a/src/mongo/util/future_impl.h b/src/mongo/util/future_impl.h index a08516191f4..ac9c4dd1fc2 100644 --- a/src/mongo/util/future_impl.h +++ b/src/mongo/util/future_impl.h @@ -45,6 +45,7 @@ #include "mongo/util/assert_util.h" #include "mongo/util/debug_util.h" #include "mongo/util/functional.h" +#include "mongo/util/hierarchical_acquisition.h" #include "mongo/util/interruptible.h" #include "mongo/util/intrusive_counter.h" #include "mongo/util/scopeguard.h" @@ -483,8 +484,9 @@ public: // These are only used to signal completion to blocking waiters. Benchmarks showed that it was // worth deferring the construction of cv, so it can be avoided when it isn't necessary. - Mutex mx = MONGO_MAKE_LATCH("FutureResolution"); // F - boost::optional<stdx::condition_variable> cv; // F (but guarded by mutex) + + Mutex mx = MONGO_MAKE_LATCH(HierarchicalAcquisitionLevel(0), "FutureResolution"); // F + boost::optional<stdx::condition_variable> cv; // F (but guarded by mutex) // This holds the children created from a SharedSemiFuture. When this SharedState is completed, // the result will be copied in to each of the children. This allows their continuations to have diff --git a/src/mongo/util/queue.h b/src/mongo/util/queue.h index 320f036e9ff..176e719cfdf 100644 --- a/src/mongo/util/queue.h +++ b/src/mongo/util/queue.h @@ -37,6 +37,7 @@ #include "mongo/platform/mutex.h" #include "mongo/stdx/chrono.h" #include "mongo/stdx/condition_variable.h" +#include "mongo/util/hierarchical_acquisition.h" namespace mongo { @@ -251,7 +252,7 @@ private: } } - mutable Mutex _lock = MONGO_MAKE_LATCH("BlockingQueue::_lock"); + mutable Mutex _lock = MONGO_MAKE_LATCH(HierarchicalAcquisitionLevel(0), "BlockingQueue::_lock"); std::queue<T> _queue; const size_t _maxSize; size_t _currentSize = 0; diff --git a/src/mongo/util/synchronized_value.h b/src/mongo/util/synchronized_value.h index 28033cd7bf8..ef1305e0b9c 100644 --- a/src/mongo/util/synchronized_value.h +++ b/src/mongo/util/synchronized_value.h @@ -30,6 +30,7 @@ #pragma once #include "mongo/platform/mutex.h" +#include "mongo/util/hierarchical_acquisition.h" namespace mongo { @@ -250,7 +251,8 @@ private: T _value; // Mutex to guard value - mutable Mutex _mutex = MONGO_MAKE_LATCH("synchronized_value::_mutex"); + mutable Mutex _mutex = + MONGO_MAKE_LATCH(HierarchicalAcquisitionLevel(0), "synchronized_value::_mutex"); }; template <class T> |