From 94678da98ea29ca6e52281a22312f2345541a790 Mon Sep 17 00:00:00 2001 From: Randolph Tan Date: Mon, 22 Oct 2018 15:21:18 -0400 Subject: SERVER-37701 Make SessionUpdateTracker include the uid portion of LogicalSessionId when tracking (cherry picked from commit df048e23d9149a3607205ae0e69ef11e881c037c) (cherry picked from commit 2faa52bdce0b0fbb73c0a4d56a0f729bf144f72b) --- src/mongo/db/repl/session_update_tracker.cpp | 8 ++++---- src/mongo/db/repl/session_update_tracker.h | 3 ++- src/mongo/db/session_catalog.cpp | 2 +- src/mongo/db/session_catalog.h | 6 +----- 4 files changed, 8 insertions(+), 11 deletions(-) diff --git a/src/mongo/db/repl/session_update_tracker.cpp b/src/mongo/db/repl/session_update_tracker.cpp index 9988a3832b9..5aa2152f5a0 100644 --- a/src/mongo/db/repl/session_update_tracker.cpp +++ b/src/mongo/db/repl/session_update_tracker.cpp @@ -65,9 +65,9 @@ void SessionUpdateTracker::_updateSessionInfo(const OplogEntry& entry) { const auto& lsid = sessionInfo.getSessionId(); invariant(lsid); - auto iter = _sessionsToUpdate.find(lsid->getId()); + auto iter = _sessionsToUpdate.find(*lsid); if (iter == _sessionsToUpdate.end()) { - _sessionsToUpdate.emplace(lsid->getId(), entry); + _sessionsToUpdate.emplace(*lsid, entry); return; } @@ -77,7 +77,7 @@ void SessionUpdateTracker::_updateSessionInfo(const OplogEntry& entry) { return; } - severe() << "Entry for session " << lsid->getId() << " has txnNumber " + severe() << "Entry for session " << lsid->toBSON() << " has txnNumber " << *sessionInfo.getTxnNumber() << " < " << *existingSessionInfo.getTxnNumber(); severe() << "New oplog entry: " << redact(entry.toString()); severe() << "Existing oplog entry: " << redact(iter->second.toString()); @@ -125,7 +125,7 @@ std::vector SessionUpdateTracker::_flushForQueryPredicate( const BSONObj& queryPredicate) { auto idField = queryPredicate["_id"].Obj(); auto lsid = LogicalSessionId::parse(IDLParserErrorContext("lsidInOplogQuery"), idField); - auto iter = _sessionsToUpdate.find(lsid.getId()); + auto iter = _sessionsToUpdate.find(lsid); if (iter == _sessionsToUpdate.end()) { return {}; diff --git a/src/mongo/db/repl/session_update_tracker.h b/src/mongo/db/repl/session_update_tracker.h index e4288324337..959ab190801 100644 --- a/src/mongo/db/repl/session_update_tracker.h +++ b/src/mongo/db/repl/session_update_tracker.h @@ -35,6 +35,7 @@ #include #include "mongo/bson/bsonobj.h" +#include "mongo/db/logical_session_id.h" #include "mongo/db/repl/oplog_entry.h" #include "mongo/util/uuid.h" @@ -82,7 +83,7 @@ private: */ void _updateSessionInfo(const OplogEntry& entry); - std::map _sessionsToUpdate; + LogicalSessionIdMap _sessionsToUpdate; }; } // namespace repl diff --git a/src/mongo/db/session_catalog.cpp b/src/mongo/db/session_catalog.cpp index 885fabb4190..738997907b0 100644 --- a/src/mongo/db/session_catalog.cpp +++ b/src/mongo/db/session_catalog.cpp @@ -188,7 +188,7 @@ void SessionCatalog::invalidateSessions(OperationContext* opCtx, << " cannot be performed using a transaction or on a session.", !opCtx->getLogicalSessionId()); - const auto invalidateSessionFn = [&](WithLock, SessionRuntimeInfoMap::iterator it) { + const auto invalidateSessionFn = [&](WithLock, decltype(_txnTable)::iterator it) { auto& sri = it->second; sri->txnState.invalidate(); diff --git a/src/mongo/db/session_catalog.h b/src/mongo/db/session_catalog.h index 17cc8e8cf4b..436a6e1f0ad 100644 --- a/src/mongo/db/session_catalog.h +++ b/src/mongo/db/session_catalog.h @@ -143,10 +143,6 @@ private: Session txnState; }; - using SessionRuntimeInfoMap = stdx::unordered_map, - LogicalSessionIdHash>; - /** * Must be called with _mutex locked and returns it locked. May release and re-acquire it zero * or more times before returning. The returned 'SessionRuntimeInfo' is guaranteed to be linked @@ -163,7 +159,7 @@ private: ServiceContext* const _serviceContext; stdx::mutex _mutex; - SessionRuntimeInfoMap _txnTable; + LogicalSessionIdMap> _txnTable; }; /** -- cgit v1.2.1