summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMisha Tyulenev <misha@mongodb.com>2018-07-03 11:50:52 -0400
committerMisha Tyulenev <misha@mongodb.com>2018-07-03 17:09:33 -0400
commit6405d65b1d6432e138b44c13085d0c2fe235d6bd (patch)
tree4abae37e4d41644655ac3ce7aff1a9c1876e1dae
parent3b1d9e47493ca10fb99899cd5aa4a792249330c0 (diff)
downloadmongo-r3.6.6-rc0.tar.gz
SERVER-34810 do not kill new sessions in logical session cacher3.6.6-rc0r3.6.6
(cherry picked from commit 57d7938c49da06122d4d43054ff89e1881d0209f)
-rw-r--r--src/mongo/db/logical_session_cache_impl.cpp13
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 2f5a2731ea4..2815c075a40 100644
--- a/src/mongo/db/logical_session_cache_impl.cpp
+++ b/src/mongo/db/logical_session_cache_impl.cpp
@@ -344,13 +344,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);