diff options
author | Randolph Tan <randolph@10gen.com> | 2018-10-22 15:21:18 -0400 |
---|---|---|
committer | Randolph Tan <randolph@10gen.com> | 2018-10-23 12:51:51 -0400 |
commit | df048e23d9149a3607205ae0e69ef11e881c037c (patch) | |
tree | fb116d1e82a1fa016bd5506ea31808304264af47 /src/mongo | |
parent | 15140764a587b404ec442d1d84502bfd0cc502cd (diff) | |
download | mongo-df048e23d9149a3607205ae0e69ef11e881c037c.tar.gz |
SERVER-37701 Make SessionUpdateTracker include the uid portion of LogicalSessionId when tracking
Diffstat (limited to 'src/mongo')
-rw-r--r-- | src/mongo/db/repl/session_update_tracker.cpp | 8 | ||||
-rw-r--r-- | src/mongo/db/repl/session_update_tracker.h | 3 | ||||
-rw-r--r-- | src/mongo/db/session_catalog.cpp | 2 | ||||
-rw-r--r-- | 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 9bdbd369437..87698aa4cbb 100644 --- a/src/mongo/db/repl/session_update_tracker.cpp +++ b/src/mongo/db/repl/session_update_tracker.cpp @@ -131,9 +131,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; } @@ -143,7 +143,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()); @@ -191,7 +191,7 @@ std::vector<OplogEntry> 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 <vector> #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<UUID, OplogEntry> _sessionsToUpdate; + LogicalSessionIdMap<OplogEntry> _sessionsToUpdate; }; } // namespace repl diff --git a/src/mongo/db/session_catalog.cpp b/src/mongo/db/session_catalog.cpp index 2478ad388db..cc1616626de 100644 --- a/src/mongo/db/session_catalog.cpp +++ b/src/mongo/db/session_catalog.cpp @@ -126,7 +126,7 @@ void SessionCatalog::invalidateSessions(OperationContext* opCtx, !opCtx->getLogicalSessionId()); } - const auto invalidateSessionFn = [&](WithLock, SessionRuntimeInfoMap::iterator it) { + const auto invalidateSessionFn = [&](WithLock, decltype(_sessions)::iterator it) { auto& sri = it->second; auto const txnParticipant = TransactionParticipant::getFromNonCheckedOutSession(&sri->txnState); diff --git a/src/mongo/db/session_catalog.h b/src/mongo/db/session_catalog.h index f759f47b91a..2da89c2fb7a 100644 --- a/src/mongo/db/session_catalog.h +++ b/src/mongo/db/session_catalog.h @@ -139,10 +139,6 @@ private: Session txnState; }; - using SessionRuntimeInfoMap = stdx::unordered_map<LogicalSessionId, - std::shared_ptr<SessionRuntimeInfo>, - LogicalSessionIdHash>; - /** * May release and re-acquire it zero or more times before returning. The returned * 'SessionRuntimeInfo' is guaranteed to be linked on the catalog's _txnTable as long as the @@ -164,7 +160,7 @@ private: stdx::mutex _mutex; // Owns the Session objects for all current Sessions. - SessionRuntimeInfoMap _sessions; + LogicalSessionIdMap<std::shared_ptr<SessionRuntimeInfo>> _sessions; // Count of the number of Sessions that are currently checked out. uint32_t _numCheckedOutSessions{0}; |