Skip to content

Commit

Permalink
GODRIVER-2539 Remove MinWireVersion < 6 Logic (mongodb#1084)
Browse files Browse the repository at this point in the history
  • Loading branch information
prestonvasquez authored Oct 10, 2022
1 parent 1205fe4 commit 5fcb147
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 1,062 deletions.
12 changes: 3 additions & 9 deletions mongo/change_stream.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
retries = 1
}
if internal.IsTimeoutContext(ctx) {
Expand Down Expand Up @@ -325,11 +325,8 @@ AggregateExecuteLoop:
}
defer conn.Close()

// If wire version is now < 6, do not retry.
// Update the wire version with data from the new connection.
cs.wireVersion = conn.Description().WireVersion
if cs.wireVersion == nil || cs.wireVersion.Max < 6 {
break AggregateExecuteLoop
}

// Reset deployment.
cs.aggregate.Deployment(cs.createOperationDeployment(server, conn))
Expand Down Expand Up @@ -435,10 +432,7 @@ func (cs *ChangeStream) createPipelineOptionsDoc() (bsoncore.Document, error) {
}

if cs.options.FullDocument != nil {
// Only append a default "fullDocument" field if wire version is less than 6 (3.6). Otherwise,
// the server will assume users want the default behavior, and "fullDocument" does not need to be
// specified.
if *cs.options.FullDocument != options.Default || (cs.wireVersion != nil && cs.wireVersion.Max < 6) {
if *cs.options.FullDocument != options.Default {
plDoc = bsoncore.AppendStringElement(plDoc, "fullDocument", string(*cs.options.FullDocument))
}
}
Expand Down
301 changes: 0 additions & 301 deletions mongo/integration/operation_legacy_test.go

This file was deleted.

22 changes: 1 addition & 21 deletions x/mongo/driver/operation.go
Original file line number Diff line number Diff line change
Expand Up @@ -505,24 +505,6 @@ func (op Operation) Execute(ctx context.Context) error {
}

desc := description.SelectedServer{Server: conn.Description(), Kind: op.Deployment.Kind()}
if desc.WireVersion == nil || desc.WireVersion.Max < 4 {
switch op.Legacy {
case LegacyFind:
return op.legacyFind(ctx, (*wm)[:0], srvr, conn, desc, maxTimeMS)
case LegacyGetMore:
return op.legacyGetMore(ctx, (*wm)[:0], srvr, conn, desc)
case LegacyKillCursors:
return op.legacyKillCursors(ctx, (*wm)[:0], srvr, conn, desc)
}
}
if desc.WireVersion == nil || desc.WireVersion.Max < 3 {
switch op.Legacy {
case LegacyListCollections:
return op.legacyListCollections(ctx, (*wm)[:0], srvr, conn, desc)
case LegacyListIndexes:
return op.legacyListIndexes(ctx, (*wm)[:0], srvr, conn, desc, maxTimeMS)
}
}

if batching {
targetBatchSize := desc.MaxDocumentSize
Expand Down Expand Up @@ -830,7 +812,6 @@ func (op Operation) retryable(desc description.Server) bool {
return true
}
if retryWritesSupported(desc) &&
desc.WireVersion != nil && desc.WireVersion.Max >= 6 &&
op.Client != nil && !(op.Client.TransactionInProgress() || op.Client.TransactionStarting()) &&
writeconcern.AckWrite(op.WriteConcern) {
return true
Expand All @@ -839,8 +820,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 &&
(op.Client == nil || !(op.Client.TransactionInProgress() || op.Client.TransactionStarting())) {
if op.Client == nil || !(op.Client.TransactionInProgress() || op.Client.TransactionStarting()) {
return true
}
}
Expand Down
Loading

0 comments on commit 5fcb147

Please sign in to comment.