diff options
author | Misha Tyulenev <misha@mongodb.com> | 2018-07-03 11:50:52 -0400 |
---|---|---|
committer | Misha Tyulenev <misha@mongodb.com> | 2018-07-03 14:29:57 -0400 |
commit | 57d7938c49da06122d4d43054ff89e1881d0209f (patch) | |
tree | 5dd9da046f95314bdb48442eec58457e6c325477 /src/mongo/db/logical_session_cache_impl.cpp | |
parent | 738ee996e0a1f5b0c92f27f2746d94d14092c1bd (diff) | |
download | mongo-57d7938c49da06122d4d43054ff89e1881d0209f.tar.gz |
SERVER-34810 do not kill new sessions in logical session cache
Diffstat (limited to 'src/mongo/db/logical_session_cache_impl.cpp')
-rw-r--r-- | src/mongo/db/logical_session_cache_impl.cpp | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/src/mongo/db/logical_session_cache_impl.cpp b/src/mongo/db/logical_session_cache_impl.cpp index 3c1082dbc35..8b46cbb4638 100644 --- a/src/mongo/db/logical_session_cache_impl.cpp +++ b/src/mongo/db/logical_session_cache_impl.cpp @@ -346,13 +346,24 @@ void LogicalSessionCacheImpl::_refresh(Client* client) { _stats.setLastSessionsCollectionJobEntriesEnded(explicitlyEndingSessions.size()); } - // Find which running, but not recently active sessions, are expired, and add them // to the list of sessions to kill cursors for KillAllSessionsByPatternSet patterns; auto openCursorSessions = _service->getOpenCursorSessions(); + // Exclude sessions added to _activeSessions from the openCursorSession to avoid race between + // killing cursors on the removed sessions and creating sessions. + { + stdx::lock_guard<stdx::mutex> lk(_cacheMutex); + + for (const auto& it : _activeSessions) { + auto newSessionIt = openCursorSessions.find(it.first); + if (newSessionIt != openCursorSessions.end()) { + openCursorSessions.erase(newSessionIt); + } + } + } // think about pruning ending and active out of openCursorSessions auto statusAndRemovedSessions = _sessionsColl->findRemovedSessions(opCtx, openCursorSessions); |