diff options
author | Blake Oler <blake.oler@mongodb.com> | 2018-10-11 11:53:09 -0400 |
---|---|---|
committer | Blake Oler <blake.oler@mongodb.com> | 2018-12-31 14:55:58 -0500 |
commit | 81a0b13992a35b69eebc07c92ba9d5d5033f13ab (patch) | |
tree | e9cb27439abb7f6100b107938dbc80d788205c4d | |
parent | 908652f33056cf7f5a58c664ed85008bab3838d5 (diff) | |
download | mongo-81a0b13992a35b69eebc07c92ba9d5d5033f13ab.tar.gz |
SERVER-37562 Reduce all IX locks to IS locks in SessionsCollectionRS
(cherry picked from commit 34de1953a9575f2745a1f430f5eb7ce2a6014031)
-rw-r--r-- | src/mongo/db/sessions_collection_rs.cpp | 17 |
1 files changed, 4 insertions, 13 deletions
diff --git a/src/mongo/db/sessions_collection_rs.cpp b/src/mongo/db/sessions_collection_rs.cpp index e45d88add8b..e916fda9d6c 100644 --- a/src/mongo/db/sessions_collection_rs.cpp +++ b/src/mongo/db/sessions_collection_rs.cpp @@ -86,16 +86,13 @@ Status makePrimaryConnection(OperationContext* opCtx, boost::optional<ScopedDbCo } template <typename Callback> -auto runIfStandaloneOrPrimary(const NamespaceString& ns, - LockMode mode, - OperationContext* opCtx, - Callback callback) +auto runIfStandaloneOrPrimary(const NamespaceString& ns, OperationContext* opCtx, Callback callback) -> boost::optional<decltype(std::declval<Callback>()())> { bool isStandaloneOrPrimary; { - Lock::DBLock lk(opCtx, ns.db(), mode); + Lock::DBLock lk(opCtx, ns.db(), MODE_IS); Lock::CollectionLock lock( - opCtx->lockState(), SessionsCollection::kSessionsNamespaceString.ns(), mode); + opCtx->lockState(), SessionsCollection::kSessionsNamespaceString.ns(), MODE_IS); auto coord = mongo::repl::ReplicationCoordinator::get(opCtx); @@ -136,13 +133,12 @@ auto sendToPrimary(OperationContext* opCtx, Callback callback) template <typename LocalCallback, typename RemoteCallback> auto dispatch(const NamespaceString& ns, - LockMode mode, OperationContext* opCtx, LocalCallback localCallback, RemoteCallback remoteCallback) -> decltype(std::declval<RemoteCallback>()(static_cast<DBClientBase*>(nullptr))) { // If we are the primary, write directly to ourself. - auto result = runIfStandaloneOrPrimary(ns, mode, opCtx, [&] { return localCallback(); }); + auto result = runIfStandaloneOrPrimary(ns, opCtx, [&] { return localCallback(); }); if (result) { return *result; @@ -156,7 +152,6 @@ auto dispatch(const NamespaceString& ns, Status SessionsCollectionRS::setupSessionsCollection(OperationContext* opCtx) { return dispatch( kSessionsNamespaceString, - MODE_IX, opCtx, [&] { auto existsStatus = checkSessionsCollectionExists(opCtx); @@ -215,7 +210,6 @@ Status SessionsCollectionRS::checkSessionsCollectionExists(OperationContext* opC Status SessionsCollectionRS::refreshSessions(OperationContext* opCtx, const LogicalSessionRecordSet& sessions) { return dispatch(kSessionsNamespaceString, - MODE_IX, opCtx, [&] { DBDirectClient client(opCtx); @@ -234,7 +228,6 @@ Status SessionsCollectionRS::refreshSessions(OperationContext* opCtx, Status SessionsCollectionRS::removeRecords(OperationContext* opCtx, const LogicalSessionIdSet& sessions) { return dispatch(kSessionsNamespaceString, - MODE_IX, opCtx, [&] { DBDirectClient client(opCtx); @@ -252,7 +245,6 @@ Status SessionsCollectionRS::removeRecords(OperationContext* opCtx, StatusWith<LogicalSessionIdSet> SessionsCollectionRS::findRemovedSessions( OperationContext* opCtx, const LogicalSessionIdSet& sessions) { return dispatch(kSessionsNamespaceString, - MODE_IS, opCtx, [&] { DBDirectClient client(opCtx); @@ -271,7 +263,6 @@ Status SessionsCollectionRS::removeTransactionRecords(OperationContext* opCtx, const LogicalSessionIdSet& sessions) { return dispatch( NamespaceString::kSessionTransactionsTableNamespace, - MODE_IX, opCtx, [&] { DBDirectClient client(opCtx); |