Skip to content

DRIVERS-2944 Update handshake spec to allow using OP_MSG exclusively#1933

Merged
Jibola merged 14 commits into
mongodb:masterfrom
sleepyStick:DRIVERS-2944
Jun 8, 2026
Merged

DRIVERS-2944 Update handshake spec to allow using OP_MSG exclusively#1933
Jibola merged 14 commits into
mongodb:masterfrom
sleepyStick:DRIVERS-2944

Conversation

@sleepyStick
Copy link
Copy Markdown
Contributor

@sleepyStick sleepyStick commented May 8, 2026

Please complete the following before merging:

  • Is the relevant DRIVERS ticket in the PR title?

@sleepyStick sleepyStick marked this pull request as ready for review May 8, 2026 23:31
@sleepyStick sleepyStick requested review from a team as code owners May 8, 2026 23:31
@sleepyStick sleepyStick requested review from blink1073, jyemin and vbabanin and removed request for a team and blink1073 May 8, 2026 23:31
@sleepyStick
Copy link
Copy Markdown
Contributor Author

removed @blink1073 (OOO currently) and requested @vbabanin instead :)

Comment thread source/mongodb-handshake/handshake.md Outdated
Comment thread source/mongodb-handshake/handshake.md Outdated
# Use OP_MSG for all future commands, including authentication.
conn.supports_op_msg = True
if reply["maxWireVersion"] < 6:
# Server is reporting that it doesn't support OpMSG
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

See above. The server "reports" it doesn't support OpMSG by hanging up the socket.

Comment thread source/message/OP_MSG.md Outdated
handshake using `OP_MSG` if an API version was declared on the client.

If no API version was declared, drivers that have historically supported MongoDB 3.4 and earlier MUST perform the
If no API version was declared, drivers that have historically supported MongoDB 3.4 and earlier MAY perform the
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I feel like this historical distinction is now irrelevant. Should we instead just say that drivers SHOULD use OP_MSG for the handshake, and MUST if load balanced mode is on or API version is specified?

Alternatively, we can just link to the handshake spec since this is duplicating what is already says there.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I like the idea of linking to the handshake spec!

Comment thread source/mongodb-handshake/handshake.md Outdated
`loadBalanced: False`, drivers MUST use legacy hello for the first message of the initial handshake with the `OP_QUERY`
protocol (before switching to `OP_MSG` if the `maxWireVersion` indicates compatibility), and include `helloOk:true` in
the handshake request.
Drivers SHOULD use the `OP_MSG` protocol for all handshakes if their minWireVersion is 6 (MongoDB 3.6) or higher. If a
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

What's the justification for SHOULD rather than MUST? Is there a reason for any driver not to do this?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

tbh i wrote SHOULD because that's what the driver ticket said https://jira.mongodb.org/browse/DRIVERS-2944
(And I justified it to myself by saying that if a driver doesn't do this they're just doing the current behaviour which isn't inherently breaking anything?)

Copy link
Copy Markdown
Contributor

@nbbeeken nbbeeken left a comment

Choose a reason for hiding this comment

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

🎉 its happeninggggg!!!! exciting times 😁

@sleepyStick sleepyStick requested a review from jyemin June 4, 2026 00:27
Comment thread source/message/OP_MSG.md Outdated
Comment thread source/message/OP_MSG.md Outdated
Comment thread source/mongodb-handshake/handshake.md Outdated
Comment thread source/mongodb-handshake/handshake.md Outdated
sleepyStick and others added 2 commits June 5, 2026 12:28
Co-authored-by: Jeff Yemin <jeff.yemin@mongodb.com>
@sleepyStick sleepyStick requested a review from jyemin June 5, 2026 20:03
Copy link
Copy Markdown
Contributor

@jyemin jyemin left a comment

Choose a reason for hiding this comment

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

OP_QUERY is dead! Long live OP_MSG!

Oh also, LGTM.

@sleepyStick sleepyStick requested a review from Jibola June 8, 2026 17:24
@Jibola
Copy link
Copy Markdown
Contributor

Jibola commented Jun 8, 2026

Bypassing and merging because @jyemin is one of the mongodb/dbx-spec-maintainters-connection-establishment members (per the Client Libraries Common Spec Maintainers document)

@Jibola Jibola merged commit e675eff into mongodb:master Jun 8, 2026
6 checks passed
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.

4 participants