-
Notifications
You must be signed in to change notification settings - Fork 888
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
Conversation
@@ -46,6 +48,69 @@ func getSentMessageParser(opcode wiremessage.OpCode) (sentMsgParseFn, bool) { | |||
} | |||
} | |||
|
|||
func parseOpQuery(wm []byte) (*SentMessage, error) { |
There was a problem hiding this comment.
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
@@ -19,4 +19,5 @@ const ( | |||
LegacyKillCursors | |||
LegacyListCollections | |||
LegacyListIndexes | |||
LegacyHandshake |
There was a problem hiding this comment.
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( |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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
API Change Report./x/mongo/drivercompatible changesLegacyHandshake: added ./x/mongo/driver/drivertestcompatible changesGetCommandFromQueryWireMessage: added |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
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