diff options
author | James Wahlin <james@mongodb.com> | 2017-06-08 09:37:29 -0400 |
---|---|---|
committer | James Wahlin <james@mongodb.com> | 2017-06-08 09:37:29 -0400 |
commit | 12e54a966bde02389224b78db6500978ca68a54e (patch) | |
tree | 815944562c042f09f9664c3e32ab00de12370215 /src/mongo/db/logical_session_cache.cpp | |
parent | 6f8b26a49dd6fb150689ecd970f47a48e15bd28b (diff) | |
download | mongo-12e54a966bde02389224b78db6500978ca68a54e.tar.gz |
Revert "SERVER-28346 Add more unit tests for the logical session cache"
This reverts commit 4c3337abe512a37c8e4cb22e16eafcd04bc5bd3a.
Diffstat (limited to 'src/mongo/db/logical_session_cache.cpp')
-rw-r--r-- | src/mongo/db/logical_session_cache.cpp | 21 |
1 files changed, 9 insertions, 12 deletions
diff --git a/src/mongo/db/logical_session_cache.cpp b/src/mongo/db/logical_session_cache.cpp index 1c94e019ac3..9ab51495f52 100644 --- a/src/mongo/db/logical_session_cache.cpp +++ b/src/mongo/db/logical_session_cache.cpp @@ -145,8 +145,8 @@ Status LogicalSessionCache::startSession(LogicalSessionRecord authoritativeRecor } void LogicalSessionCache::_refresh() { - LogicalSessionIdSet activeSessions; - LogicalSessionIdSet deadSessions; + SessionList activeSessions; + SessionList deadSessions; auto now = _service->now(); @@ -164,9 +164,9 @@ void LogicalSessionCache::_refresh() { for (auto& it : cacheCopy) { auto record = it.second; if (!_isDead(record, now)) { - activeSessions.insert(record.getLsid()); + activeSessions.push_back(record.getLsid()); } else { - deadSessions.insert(record.getLsid()); + deadSessions.push_back(record.getLsid()); } } @@ -190,28 +190,25 @@ void LogicalSessionCache::_refresh() { // by another thread. it->second.setLastUse(now); } - - activeSessions.insert(lsid); } } + activeSessions.splice(activeSessions.begin(), serviceSessions); + // Query into the sessions collection to do the refresh. If any sessions have // failed to refresh, it means their authoritative records were removed, and // we should remove such records from our cache as well. auto failedToRefresh = _sessionsColl->refreshSessions(std::move(activeSessions)); + deadSessions.splice(deadSessions.begin(), failedToRefresh); // Prune any dead records out of the cache. Dead records are ones that failed to // refresh, or ones that have expired locally. We don't make an effort to check // if the locally-expired records still have live authoritative records in the // sessions collection. We also don't attempt to resurrect our expired records. - // However, we *do* keep records alive if they are active on the service. { stdx::unique_lock<stdx::mutex> lk(_cacheMutex); - for (auto deadId : failedToRefresh) { - auto it = serviceSessions.find(deadId); - if (it == serviceSessions.end()) { - _cache.erase(deadId); - } + for (auto deadId : deadSessions) { + _cache.erase(deadId); } } } |