summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRandolph Tan <randolph@10gen.com>2018-10-22 15:21:18 -0400
committerRandolph Tan <randolph@10gen.com>2018-10-23 14:53:39 -0400
commit94678da98ea29ca6e52281a22312f2345541a790 (patch)
tree02de95e49ff8b090e8924b1b9c6d9b056398a57f
parent3bf02defe2e16b9de339fca4717d3d65ee779eac (diff)
downloadmongo-94678da98ea29ca6e52281a22312f2345541a790.tar.gz
SERVER-37701 Make SessionUpdateTracker include the uid portion of LogicalSessionId when tracking
(cherry picked from commit df048e23d9149a3607205ae0e69ef11e881c037c) (cherry picked from commit 2faa52bdce0b0fbb73c0a4d56a0f729bf144f72b)
-rw-r--r--src/mongo/db/repl/session_update_tracker.cpp8
-rw-r--r--src/mongo/db/repl/session_update_tracker.h3
-rw-r--r--src/mongo/db/session_catalog.cpp2
-rw-r--r--src/mongo/db/session_catalog.h6
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<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 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<LogicalSessionId,
- std::shared_ptr<SessionRuntimeInfo>,
- 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<std::shared_ptr<SessionRuntimeInfo>> _txnTable;
};
/**