Repository navigation
Conversation
ServerSession.hasTimedOut reduced the elapsed idle time modulo a day and then an hour before comparing it to logicalSessionTimeoutMinutes. A session idle for 60 minutes was treated as idle for 0, so the pool reused an lsid the server may already have expired. That happened again every hour. Compare the elapsed minutes directly. The one-minute margin (timeout - 1) is unchanged. The pool tests that passed 30 * 60 * 1000 into hasTimedOut were passing milliseconds to a minutes parameter, so they could not fail.
Contributor
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Summary of Changes
ServerSession.hasTimedOutnow compares elapsed idle minutes withlogicalSessionTimeoutMinutesdirectly. It no longer reduces that duration modulo one day and then modulo one hour.Notes for Reviewers
The
- 1minute comparison is the existing "within one minute of expiry, do not reuse" rule.Math.roundis gone so a fractional minute cannot change which side of that boundary a session falls on. 9.5 minutes against a 10 minute timeout is still not reused (9.5 > 9).Jira: NODE-7984
What is the motivation for this change?
A pooled server session idle longer than
logicalSessionTimeoutMinuteswas returned to the application during part of every hour. Commands then sent an lsid the server was allowed to have expired.For bug fixes
Current (incorrect) behavior:
Idle time is folded into 0–59 minutes. With a 30 minute timeout, a session idle for 60, 120, 180, ... minutes is reused. With the driver's mock/default 10 minute timeout, a session idle for 60 minutes is reused (
0 > 9is false).Expected behavior:
Idle time is the elapsed minutes since
lastUse. The session is not reused when that value is greater thanlogicalSessionTimeoutMinutes - 1.How to reproduce:
Unit coverage:
test/unit/sessions.test.ts("does not reuse a session idle for one hour when the timeout is 30 minutes").Affected versions:
The modulo is present on main (7.x / 6.x). It does not depend on a server version or topology. The server default for
logicalSessionTimeoutMinutesis 30. When the topology has not reported a timeout, the pool uses 10.Double check the following
npm run check:lint)type(NODE-xxxx)[!]: descriptionfeat(NODE-1234)!: rewriting everything in coffeescript