summaryrefslogtreecommitdiff
path: root/src/mongo/s
diff options
context:
space:
mode:
authorCheahuychou Mao <mao.cheahuychou@gmail.com>2022-05-31 14:36:05 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2022-06-01 23:26:39 +0000
commit05683c2d9d9654079df750e9ac5f389a10068b63 (patch)
treea769cb4581663605343f810f0bcdf5785c1b2b80 /src/mongo/s
parentd94581d33ce3ace6b69e7445f16ee15e1308135e (diff)
downloadmongo-05683c2d9d9654079df750e9ac5f389a10068b63.tar.gz
SERVER-66850 Make the LogicalSessionCache reaper only scan parent sessions when searching for expired logical sessions
(cherry picked from commit d461c7c2fb3197b82585099f7aa7c1a07f2223db)
Diffstat (limited to 'src/mongo/s')
-rw-r--r--src/mongo/s/session_catalog_router.cpp21
1 files changed, 9 insertions, 12 deletions
diff --git a/src/mongo/s/session_catalog_router.cpp b/src/mongo/s/session_catalog_router.cpp
index aef732d30b0..6bbe4e8af65 100644
--- a/src/mongo/s/session_catalog_router.cpp
+++ b/src/mongo/s/session_catalog_router.cpp
@@ -45,18 +45,15 @@ int RouterSessionCatalog::reapSessionsOlderThan(OperationContext* opCtx,
// Find the possibly expired logical session ids in the in-memory catalog.
LogicalSessionIdSet possiblyExpiredLogicalSessionIds;
- catalog->scanSessions(
- SessionKiller::Matcher(KillAllSessionsByPatternSet{makeKillAllSessionsByPattern(opCtx)}),
- [&](const ObservableSession& session) {
- const auto sessionId = session.getSessionId();
-
- // Skip child transaction sessions since they correspond to the same logical session as
- // their parent transaction session so they have the same last check-out time as the
- // the parent's.
- if (session.getLastCheckout() < possiblyExpired && !getParentSessionId(sessionId)) {
- possiblyExpiredLogicalSessionIds.insert(session.getSessionId());
- }
- });
+ // Skip child transaction sessions since they correspond to the same logical session as their
+ // parent transaction session so they have the same last check-out time as the parent's.
+ catalog->scanParentSessions([&](const ObservableSession& session) {
+ const auto sessionId = session.getSessionId();
+ invariant(!getParentSessionId(sessionId));
+ if (session.getLastCheckout() < possiblyExpired) {
+ possiblyExpiredLogicalSessionIds.insert(session.getSessionId());
+ }
+ });
// From the possibly expired logical session ids, find the ones that have been removed from
// from the config.system.sessions collection.
auto expiredLogicalSessionIds =