Skip to content

GODRIVER-2218 Bump connection idle deadline on pool checkIn. #869

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

matthewdale
Copy link
Collaborator

@matthewdale matthewdale commented Mar 10, 2022

GODRIVER-2218

Currently a connection's "idle deadline" is increased in the Go driver only when reading writing to the connection. However, the CMAP spec defines "idle" as:

Idle: The Connection is currently "available" (as defined below) and has been for longer than maxIdleTimeMS.

"Available" is defined as:

The Connection has been established and is waiting in the pool to be checked out.

As a result, it's currently possible to check in a connection to the pool that has not been read from or written to for more than maxIdleTimeMS and it will be considered stale due to idle timeout. According to the definition of "idle" in the CMAP spec, that should be impossible.

Bump the connection idle deadline when checking connections into the pool.

Changes:

  • Run conn.bumpIdleDeadline() in pool.checkInNoEvent().
  • Remove all other calls to conn.bumpIdleDeadline() because they are now unnecessary.
  • Add a test that asserts checked-out but unused connections are not considered idle.
  • Add a test that asserts connections checked in by maintain() have an idle deadline set.

@matthewdale matthewdale force-pushed the godriver2218-bump-idle-checkin branch from 33034cc to 892848a Compare March 10, 2022 02:02
@benjirewis
Copy link
Contributor

I think those failures on latest are unrelated?

Copy link
Contributor

@kevinAlbs kevinAlbs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Good catch on the mismatched behavior with the spec!

@matthewdale matthewdale force-pushed the godriver2218-bump-idle-checkin branch from c27759d to 10c3332 Compare March 16, 2022 23:14
@matthewdale matthewdale force-pushed the godriver2218-bump-idle-checkin branch from 10c3332 to fab59cf Compare March 17, 2022 04:03
@matthewdale matthewdale merged commit 6f63c26 into mongodb:master Mar 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants