Skip to content

GODRIVER-2539 Remove MinWireVersion < 6 Logic #1084

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
merged 5 commits into from
Oct 10, 2022

Conversation

prestonvasquez
Copy link
Member

@prestonvasquez prestonvasquez commented Oct 3, 2022

GODRIVER-2539

#1063 bumps the minimum wire version from 2 to 6. The scope of GODRIVER-2539 is to remove logic dependent on MinWireVersion < 6 in "x/mongo/driver/operation.go" and "mongo/change_stream.go".

Deprecating "mongo/integration/operation_legacy_test.go"

In an internal discussion about this ticket, the following came up:

If converting the tests to use and test OpMsg would be reasonably quick and not duplicate existing test coverage, then that could be a good way to increase existing test coverage.

The tests in this file use the function validateQueryWireMessage which is wiremessage.ReadQuery* focused. Most of these "ReadQuery" functions do not have "ReadMsg" analogue, the only one being ReadQueryFlags. ReadMsgFlags already has test coverage here.

Deprecating "x/mongo/driver/operation_legacy.go"

The functionality of this file is exclusively used in the two legacy branches removed from the "driver.Operation#Execute" function and was untested outside of "mongo/integration/operation_legacy_test.go".

Copy link
Contributor

@benjirewis benjirewis left a comment

Choose a reason for hiding this comment

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

🙌 for cleanup. Just a few comments about further simplifying wire version checks.

@@ -287,7 +287,7 @@ func (cs *ChangeStream) executeOperation(ctx context.Context, resuming bool) err
// Execute the aggregate, retrying on retryable errors once (1) if retryable reads are enabled and
// infinitely (-1) if context is a Timeout context.
var retries int
if cs.client.retryReads && cs.wireVersion != nil && cs.wireVersion.Max >= 6 {
if cs.client.retryReads && cs.wireVersion != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
if cs.client.retryReads && cs.wireVersion != nil {
if cs.client.retryReads {

The previous check seemed to set retries = 1 if retryable reads were enabled and the wire version was known and greater than or equal to 6. I believe the cs.wireVersion != nil check here used the < 6 wire version logic when the wire version was unknown. I think we can remove it and always operate under the assumption that wire version is greater than 6 given that we no longer support earlier wire versions.

Copy link
Member Author

@prestonvasquez prestonvasquez Oct 4, 2022

Choose a reason for hiding this comment

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

@benjirewis I don't quite follow this. So cs.wireVersion would only be nil if the wire version was < 6?

cs.wireVersion = conn.Description().WireVersion
if cs.wireVersion == nil || cs.wireVersion.Max < 6 {
if cs.wireVersion == nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

See my previous comment. I think we can remove this entire wire version check.

@@ -830,7 +812,7 @@ func (op Operation) retryable(desc description.Server) bool {
return true
}
if retryWritesSupported(desc) &&
desc.WireVersion != nil && desc.WireVersion.Max >= 6 &&
desc.WireVersion != nil &&
Copy link
Contributor

Choose a reason for hiding this comment

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

See my previous comment. I think we can remove the desc.WireVersion != nil piece of this conditional.

@@ -839,7 +821,7 @@ func (op Operation) retryable(desc description.Server) bool {
if op.Client != nil && (op.Client.Committing || op.Client.Aborting) {
return true
}
if desc.WireVersion != nil && desc.WireVersion.Max >= 6 &&
if desc.WireVersion != nil &&
Copy link
Contributor

Choose a reason for hiding this comment

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

See my previous comment. I think we can remove the desc.WireVersion != nil piece of this conditional.

@benjirewis
Copy link
Contributor

Now that we don't need to check wire version for resuming change streams, I wonder if we can simplify executeOperation in change_stream.go to rely on server-selection/connection-checkout in operation.Execute instead of doing it manually. Not sure that's in the scope of this ticket, but I'll look into it + file another ticket.

@@ -325,12 +325,6 @@ AggregateExecuteLoop:
}
defer conn.Close()

// If wire version is now < 6, do not retry.
cs.wireVersion = conn.Description().WireVersion
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we need to update the wireVersion?

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah yes, I think we should. Nice catch, thank you!

Copy link
Collaborator

@qingyang-hu qingyang-hu left a comment

Choose a reason for hiding this comment

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

LGTM!

Copy link
Contributor

@benjirewis benjirewis left a comment

Choose a reason for hiding this comment

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

Looks good! Thanks

@prestonvasquez prestonvasquez merged commit 5fcb147 into mongodb:master Oct 10, 2022
@prestonvasquez prestonvasquez deleted the GODRIVER-2539 branch October 10, 2022 16:15
Julien-Beezeelinx pushed a commit to Julien-Beezeelinx/mongo-go-driver that referenced this pull request Oct 20, 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