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

GODRIVER-2935 Use OP_QUERY in connection handshakes #1377

Merged
merged 7 commits into from
Sep 7, 2023

Conversation

prestonvasquez
Copy link
Collaborator

GODRIVER-2935

Summary

Add OP_QUERY back to to operation execute's construction of wire messages, but specifically for handshake requests.

Background & Motivation

GODRIVER-2892 deprecated 3.4. server support and removed the usage of OP_QUERY from the code. Incidentally, removing the "createQueryWireMessage" operation method also prevents handshakes from using OP_QUERY , which is a spec requirement: https://github.com/mongodb/specifications/blob/master/source/mongodb-handshake/handshake.rst#connection-handshake

@@ -46,6 +48,69 @@ func getSentMessageParser(opcode wiremessage.OpCode) (sentMsgParseFn, bool) {
}
}

func parseOpQuery(wm []byte) (*SentMessage, error) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is a direct copy and paste of the code removed in this commit: 4449617

@prestonvasquez prestonvasquez temporarily deployed to api-report September 6, 2023 19:16 — with GitHub Actions Inactive
@@ -19,4 +19,5 @@ const (
LegacyKillCursors
LegacyListCollections
LegacyListIndexes
LegacyHandshake
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Use "operation.Legacy == LegacyHandshake" so that the operation knows that the current operation should use a legacy handshake, as defined by the specifications: "API version is not requested and loadBalanced: False", if this is the first message.

@@ -1103,6 +1104,85 @@ func (op Operation) addBatchArray(dst []byte) []byte {
return dst
}

func (op Operation) createLegacyHandshakeWireMessage(
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is a direct copy and paste of the code removed in this commit: 4449617

maxTimeMS uint64,
conn Connection,
) ([]byte, startedInformation, error) {
if isLegacyHandshake(op, desc) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

See here for the exact logic of this:

If server API version is not requested and 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.

@@ -1207,12 +1209,41 @@ func TestServer_ProcessError(t *testing.T) {
func includesClientMetadata(t *testing.T, wm []byte) bool {
t.Helper()

doc, err := drivertest.GetCommandFromMsgWireMessage(wm)
assert.NoError(t, err)
var ok bool
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is a direct copy and paste of the code removed in this commit: 4449617

@prestonvasquez prestonvasquez marked this pull request as ready for review September 6, 2023 19:27
@prestonvasquez prestonvasquez requested a review from a team as a code owner September 6, 2023 19:27
@prestonvasquez prestonvasquez requested review from blink1073 and removed request for a team September 6, 2023 19:27
@github-actions
Copy link

github-actions bot commented Sep 6, 2023

API Change Report

./x/mongo/driver

compatible changes

LegacyHandshake: added

./x/mongo/driver/drivertest

compatible changes

GetCommandFromQueryWireMessage: added

Copy link
Member

@blink1073 blink1073 left a comment

Choose a reason for hiding this comment

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

LGTM!

@prestonvasquez prestonvasquez temporarily deployed to api-report September 7, 2023 00:53 — with GitHub Actions Inactive
@prestonvasquez prestonvasquez temporarily deployed to api-report September 7, 2023 15:22 — with GitHub Actions Inactive
@prestonvasquez prestonvasquez temporarily deployed to api-report September 7, 2023 18:24 — with GitHub Actions Inactive
@prestonvasquez prestonvasquez merged commit 3bef0e4 into mongodb:master Sep 7, 2023
21 checks passed
@prestonvasquez prestonvasquez deleted the GODRIVER-2935 branch September 7, 2023 21:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants