A lack of testing exists around verifying that sessions do indeed expire from the sessions collection when their lifetime is up.
The session expiry time is a server parameter, measured in minutes. We may want to consider increasing the granularity to seconds so we don't make tests wait an abnormal amount of time.
Proposed Fix
- Change the granularity of the logical session timeout to seconds instead of minutes. Since the drivers rely on the parameter "localLogicalSessionTimeoutMinutes" to exist in calls to isMaster(), I can take the following approaches:
- Create a duplicate parameter "logicalSessionTimeoutSeconds" which will be in the granularity of seconds... I'm not sure how this would work, and what precedent exists for duplicating parameters.
- Set the timeout to X seconds internally if test commands are enabled. I don't think this would play nicely with tests, but I haven't verified.
- Talk to drivers for a possible downstream change to "logicalSessionTimeoutSeconds" completely.
- Add a test case that will run "find, wait for TTL*0.5, getMore, wait for TTL*0.5, getMore, wait for TTL*0.5, getMore, close cursor, verify the session exists" i.e. verify that the cursors remain open and the session is not expired.
- Once the workload is over wait for the TTL *1.5 and check that there are no sessions in the collection
- No need to manually invoke any refresh commands, the getMore execution guarantees that sessions are there.