Skip to content
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

Do not perform server selection to determine sessions support #1092

Merged
merged 6 commits into from
Mar 9, 2023

Conversation

jyemin
Copy link
Contributor

@jyemin jyemin commented Mar 1, 2023

Instead, check for session support during operation execution after the connection is checked out.

JAVA-4860

Instead, check for session support during operation execution
after the connection is checked out.

JAVA-4860
@jyemin jyemin self-assigned this Mar 1, 2023
JAVA-4860
JAVA-4860
JAVA-4860
@@ -221,8 +221,14 @@ private List<BsonElement> getExtraElements(final SessionContext sessionContext)
if (sessionContext.getClusterTime() != null) {
extraElements.add(new BsonElement("$clusterTime", sessionContext.getClusterTime()));
}
if (sessionContext.hasSession() && responseExpected) {
extraElements.add(new BsonElement("lsid", sessionContext.getSessionId()));
if (sessionContext.hasSession()) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is really the crux of the whole change. A few notes:

  • All application-initiated messages now have a session, so the only time this is false is for SDAM-related connection
  • This seems a bit late to be checking for unsupported explicit sessions, but it's the only place to put it that wouldn't result in code duplication, since sync and async paths all end up here
  • In practice, almost every server that the driver could actually connect to (3.6+) supports sessions, so the only time isSessionSupported will return false is a 3.6 server in 3.4 FCV mode, or a mongocryptd server.

@jyemin jyemin requested review from katcharov and rozza March 2, 2023 22:50
@jyemin jyemin requested a review from katcharov March 3, 2023 21:49
Copy link
Contributor

@katcharov katcharov left a comment

Choose a reason for hiding this comment

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

LGTM!

@jyemin jyemin merged commit dfd6e7c into mongodb:master Mar 9, 2023
@jyemin jyemin deleted the j4860 branch March 9, 2023 13:30
ispringer pushed a commit to evergage/mongo-java-driver that referenced this pull request May 16, 2023
…b#1092)

Instead, check for session support during operation execution
after the connection is checked out.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants