[SERVER-33697] Provide sanity check on number of cached sessions Created: 06/Mar/18  Updated: 29/Oct/23  Resolved: 09/Jul/18

Status: Closed
Project: Core Server
Component/s: Sharding
Affects Version/s: None
Fix Version/s: 3.6.7, 4.0.1, 4.1.1

Type: Improvement Priority: Major - P3
Reporter: Bruce Lucas (Inactive) Assignee: Cheahuychou Mao
Resolution: Fixed Votes: 0
Labels: ShardingTechDebt
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Backports
Depends
Documented
is documented by DOCS-11904 Docs for SERVER-33697: Provide sanity... Closed
Related
is related to DRIVERS-453 Decrease likelihood of implicit sessi... Closed
Backwards Compatibility: Minor Change
Backport Requested:
v4.0, v3.6
Sprint: Sharding 2018-07-16
Participants:

 Description   

Driver or application errors can result in an unbounded number of cached sessions, and that can result in performance degradation and eventually OOM. It would be useful to provide a sanity check, say at 1 M cached sessions, and warn or refuse further sessions when it is exceeded.

Fix Implementation

The commands that add new sessions to the cache are start_session_command, refresh_sessions_command and refresh_sessions_command_internal. These commands will now return false when the cache is full. The maximum number of sessions can be configured through an optional argument to the mongod command (maxSessions) and will default to 1M. LogicalSessionCacheImpl::_addToCache https://github.com/mongodb/mongo/blob/master/src/mongo/db/logical_session_cache_impl.cpp#L102  and LogicalSessionCacheImpl::startSession will now return a Status instead of void.



 Comments   
Comment by Githook User [ 11/Jul/18 ]

Author:

{'username': 'cheahuychou', 'name': 'Cheahuychou Mao', 'email': 'cheahuychou.mao@mongodb.com'}

Message: SERVER-33697 Provide sanity check on the number of cached sessions

(cherry picked from commit ffbaee1a4dcb47a307986cb696807fe979f4a39d)
Branch: v3.6
https://github.com/mongodb/mongo/commit/def12b4a903bcf0dea6211f25ccbc5e0613fe5b2

Comment by Githook User [ 09/Jul/18 ]

Author:

{'username': 'cheahuychou', 'name': 'Cheahuychou Mao', 'email': 'cheahuychou.mao@mongodb.com'}

Message: SERVER-33697 Provide sanity check on the number of cached sessions

(cherry picked from commit ffbaee1a4dcb47a307986cb696807fe979f4a39d)
Branch: v4.0
https://github.com/mongodb/mongo/commit/4f26a981c06b39e44f10d5a8a567e9e2e76baf0b

Comment by Githook User [ 09/Jul/18 ]

Author:

{'username': 'cheahuychou', 'name': 'Cheahuychou Mao', 'email': 'cheahuychou.mao@mongodb.com'}

Message: SERVER-33697 Provide sanity check on the number of cached sessions
Branch: master
https://github.com/mongodb/mongo/commit/ffbaee1a4dcb47a307986cb696807fe979f4a39d

Comment by Cheahuychou Mao [ 03/Jul/18 ]

misha.tyulenev Could you please take a look at the fix suggestions in the "Fix Implementation" section? It is mostly what we discussed offline, just that I think the change will also affect the refresh sessions commands.

Comment by Kaloian Manassiev [ 28/Jun/18 ]

misha.tyulenev, can you please work with Chou to figure out the best way to cap the number of active sessions?

Generated at Thu Feb 08 04:34:17 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.