Skip to content

Commit

Permalink
GODRIVER-3098 Drop support for MongoDB 3.6
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewdale committed Feb 7, 2025
1 parent f99da4d commit 725480c
Show file tree
Hide file tree
Showing 27 changed files with 177 additions and 265 deletions.
17 changes: 0 additions & 17 deletions .evergreen/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1668,10 +1668,6 @@ axes:
display_name: "4.0"
variables:
VERSION: "4.0"
- id: "3.6"
display_name: "3.6"
variables:
VERSION: "3.6"
- id: "rapid"
display_name: "rapid"
variables:
Expand Down Expand Up @@ -2094,19 +2090,6 @@ buildvariants:
tasks:
- name: ".goleak"

- matrix_name: "tests-rhel-36-with-zlib-support"
tags: ["pullrequest"]
matrix_spec: { version: ["3.6"], os-ssl-32: ["rhel87-64"] }
display_name: "${version} ${os-ssl-32}"
tasks:
- name: ".test !.enterprise-auth !.snappy !.zstd"

- matrix_name: "tests-windows-36-with-zlib-support"
matrix_spec: { version: ["3.6"], os-ssl-32: ["windows-64"] }
display_name: "${version} ${os-ssl-32}"
tasks:
- name: ".test !.enterprise-auth !.snappy !.zstd"

- matrix_name: "tests-rhel-40-with-snappy-support"
tags: ["pullrequest"]
matrix_spec: { version: ["4.0"], os-ssl-40: ["rhel87-64"] }
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ See the following resources to learn more about upgrading from version 1.x to 2.

- Go 1.18 or higher. We aim to support the latest versions of Go.
- Go 1.22 or higher is required to run the driver test suite.
- MongoDB 3.6 and higher.
- MongoDB 4.0 and higher.

## Installation

Expand Down
2 changes: 1 addition & 1 deletion internal/driverutil/description.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
)

const (
MinWireVersion = 6
MinWireVersion = 7
MaxWireVersion = 25
)

Expand Down
34 changes: 0 additions & 34 deletions internal/integration/causal_consistency_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -201,40 +201,6 @@ func TestCausalConsistency_Supported(t *testing.T) {
})
}

func TestCausalConsistency_NotSupported(t *testing.T) {
// use RunOnBlock instead of mtest.NewOptions().MaxServerVersion("3.4").Topologies(mtest.Single) because
// these tests should be run on servers <= 3.4 OR standalones
rob := []mtest.RunOnBlock{
{MaxServerVersion: "3.4"},
{Topology: []mtest.TopologyKind{mtest.Single}},
}
mt := mtest.New(t, mtest.NewOptions().RunOn(rob...).CreateClient(false))

mt.Run("afterClusterTime not included", func(mt *mtest.T) {
// a read in a causally consistent session does not include afterClusterTime in a deployment that does not
// support cluster times

sessOpts := options.Session().SetCausalConsistency(true)
_ = mt.Client.UseSessionWithOptions(context.Background(), sessOpts, func(ctx context.Context) error {
_, _ = mt.Coll.Find(ctx, bson.D{})
return nil
})

evt := mt.GetStartedEvent()
assert.Equal(mt, "find", evt.CommandName, "expected command 'find', got '%v'", evt.CommandName)
checkOperationTime(mt, evt.Command, false)
})
mt.Run("clusterTime not included", func(mt *mtest.T) {
// $clusterTime should not be included in commands if the deployment does not support cluster times

_ = mt.Coll.FindOne(context.Background(), bson.D{})
evt := mt.GetStartedEvent()
assert.Equal(mt, "find", evt.CommandName, "expected command 'find', got '%v'", evt.CommandName)
_, err := evt.Command.LookupErr("$clusterTime")
assert.NotNil(mt, err, "expected $clusterTime to not be sent, but was")
})
}

func checkOperationTime(mt *mtest.T, cmd bson.Raw, shouldInclude bool) {
mt.Helper()

Expand Down
5 changes: 0 additions & 5 deletions internal/integration/index_view_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -528,11 +528,6 @@ func TestIndexView(t *testing.T) {
Unique: nil,
},
}
if mtest.CompareServerVersions(mtest.ServerVersion(), "3.4") < 0 {
for _, expectedSpec := range expectedSpecs {
expectedSpec.Version = 1
}
}

specs, err := mt.Coll.Indexes().ListSpecifications(context.Background())
assert.Nil(mt, err, "ListSpecifications error: %v", err)
Expand Down
65 changes: 35 additions & 30 deletions mongo/bulk_write_models.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,13 @@ func (dom *DeleteOneModel) SetCollation(collation *options.Collation) *DeleteOne
return dom
}

// SetHint specifies the index to use for the operation. This should either be the index name as a string or the index
// specification as a document. This option is only valid for MongoDB versions >= 4.4. Server versions >= 3.4 will
// return an error if this option is specified. For server versions < 3.4, the driver will return a client-side error if
// this option is specified. The driver will return an error if this option is specified during an unacknowledged write
// operation. The driver will return an error if the hint parameter is a multi-key map. The default value is nil, which
// means that no hint will be sent.
// SetHint specifies the index to use for the operation. This should either be
// the index name as a string or the index specification as a document. This
// option is only valid for MongoDB versions >= 4.4. Server versions < 4.4 will
// return an error if this option is specified. The driver will return an error
// if this option is specified during an unacknowledged write operation. The
// driver will return an error if the hint parameter is a multi-key map. The
// default value is nil, which means that no hint will be sent.
func (dom *DeleteOneModel) SetHint(hint interface{}) *DeleteOneModel {
dom.Hint = hint
return dom
Expand Down Expand Up @@ -111,12 +112,13 @@ func (dmm *DeleteManyModel) SetCollation(collation *options.Collation) *DeleteMa
return dmm
}

// SetHint specifies the index to use for the operation. This should either be the index name as a string or the index
// specification as a document. This option is only valid for MongoDB versions >= 4.4. Server versions >= 3.4 will
// return an error if this option is specified. For server versions < 3.4, the driver will return a client-side error if
// this option is specified. The driver will return an error if this option is specified during an unacknowledged write
// operation. The driver will return an error if the hint parameter is a multi-key map. The default value is nil, which
// means that no hint will be sent.
// SetHint specifies the index to use for the operation. This should either be
// the index name as a string or the index specification as a document. This
// option is only valid for MongoDB versions >= 4.4. Server versions < 4.4 will
// return an error if this option is specified. The driver will return an error
// if this option is specified during an unacknowledged write operation. The
// driver will return an error if the hint parameter is a multi-key map. The
// default value is nil, which means that no hint will be sent.
func (dmm *DeleteManyModel) SetHint(hint interface{}) *DeleteManyModel {
dmm.Hint = hint
return dmm
Expand All @@ -141,12 +143,13 @@ func NewReplaceOneModel() *ReplaceOneModel {
return &ReplaceOneModel{}
}

// SetHint specifies the index to use for the operation. This should either be the index name as a string or the index
// specification as a document. This option is only valid for MongoDB versions >= 4.2. Server versions >= 3.4 will
// return an error if this option is specified. For server versions < 3.4, the driver will return a client-side error if
// this option is specified. The driver will return an error if this option is specified during an unacknowledged write
// operation. The driver will return an error if the hint parameter is a multi-key map. The default value is nil, which
// means that no hint will be sent.
// SetHint specifies the index to use for the operation. This should either be
// the index name as a string or the index specification as a document. This
// option is only valid for MongoDB versions >= 4.2. Server versions < 4.2 will
// return an error if this option is specified. The driver will return an error
// if this option is specified during an unacknowledged write operation. The
// driver will return an error if the hint parameter is a multi-key map. The
// default value is nil, which means that no hint will be sent.
func (rom *ReplaceOneModel) SetHint(hint interface{}) *ReplaceOneModel {
rom.Hint = hint
return rom
Expand Down Expand Up @@ -210,12 +213,13 @@ func NewUpdateOneModel() *UpdateOneModel {
return &UpdateOneModel{}
}

// SetHint specifies the index to use for the operation. This should either be the index name as a string or the index
// specification as a document. This option is only valid for MongoDB versions >= 4.2. Server versions >= 3.4 will
// return an error if this option is specified. For server versions < 3.4, the driver will return a client-side error if
// this option is specified. The driver will return an error if this option is specified during an unacknowledged write
// operation. The driver will return an error if the hint parameter is a multi-key map. The default value is nil, which
// means that no hint will be sent.
// SetHint specifies the index to use for the operation. This should either be
// the index name as a string or the index specification as a document. This
// option is only valid for MongoDB versions >= 4.2. Server versions < 4.2 will
// return an error if this option is specified. The driver will return an error
// if this option is specified during an unacknowledged write operation. The
// driver will return an error if the hint parameter is a multi-key map. The
// default value is nil, which means that no hint will be sent.
func (uom *UpdateOneModel) SetHint(hint interface{}) *UpdateOneModel {
uom.Hint = hint
return uom
Expand Down Expand Up @@ -285,12 +289,13 @@ func NewUpdateManyModel() *UpdateManyModel {
return &UpdateManyModel{}
}

// SetHint specifies the index to use for the operation. This should either be the index name as a string or the index
// specification as a document. This option is only valid for MongoDB versions >= 4.2. Server versions >= 3.4 will
// return an error if this option is specified. For server versions < 3.4, the driver will return a client-side error if
// this option is specified. The driver will return an error if this option is specified during an unacknowledged write
// operation. The driver will return an error if the hint parameter is a multi-key map. The default value is nil, which
// means that no hint will be sent.
// SetHint specifies the index to use for the operation. This should either be
// the index name as a string or the index specification as a document. This
// option is only valid for MongoDB versions >= 4.2. Server versions < 4.2 will
// return an error if this option is specified. The driver will return an error
// if this option is specified during an unacknowledged write operation. The
// driver will return an error if the hint parameter is a multi-key map. The
// default value is nil, which means that no hint will be sent.
func (umm *UpdateManyModel) SetHint(hint interface{}) *UpdateManyModel {
umm.Hint = hint
return umm
Expand Down
6 changes: 2 additions & 4 deletions mongo/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,7 @@ func (db *Database) Collection(name string, opts ...options.Lister[options.Colle
return newCollection(db, name, opts...)
}

// Aggregate executes an aggregate command the database. This requires MongoDB version >= 3.6 and driver version >=
// 1.1.0.
// Aggregate executes an aggregate command the database.
//
// The pipeline parameter must be a slice of documents, each representing an aggregation stage. The pipeline
// cannot be nil but can be empty. The stage documents must all be non-nil. For a pipeline of bson.D documents, the
Expand Down Expand Up @@ -873,8 +872,7 @@ func (db *Database) createCollectionOperation(
}

// CreateView executes a create command to explicitly create a view on the server. See
// https://www.mongodb.com/docs/manual/core/views/ for more information about views. This method requires driver version >=
// 1.4.0 and MongoDB version >= 3.4.
// https://www.mongodb.com/docs/manual/core/views/ for more information about views.
//
// The viewName parameter specifies the name of the view to create.
//
Expand Down
11 changes: 4 additions & 7 deletions mongo/options/aggregateoptions.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,7 @@ func (ao *AggregateOptionsBuilder) SetBatchSize(i int32) *AggregateOptionsBuilde
}

// SetBypassDocumentValidation sets the value for the BypassDocumentValidation field. If true, writes
// executed as part of the operation will opt out of document-level validation on the server. This
// option is valid for MongoDB versions >= 3.2 and is ignored for previous server versions. The default value
// executed as part of the operation will opt out of document-level validation on the server. The default value
// is false. See https://www.mongodb.com/docs/manual/core/schema-validation/ for more information about
// document validation.
func (ao *AggregateOptionsBuilder) SetBypassDocumentValidation(b bool) *AggregateOptionsBuilder {
Expand All @@ -84,9 +83,8 @@ func (ao *AggregateOptionsBuilder) SetBypassDocumentValidation(b bool) *Aggregat
return ao
}

// SetCollation sets the value for the Collation field. Specifies a collation to use for string
// comparisons during the operation. This option is only valid for MongoDB versions >= 3.4. For previous
// server versions, the driver will return an error if this option is used. The default value is nil,
// SetCollation sets the value for the Collation field. Specifies a collation to
// use for string comparisons during the operation. The default value is nil,
// which means the default collation of the collection will be used.
func (ao *AggregateOptionsBuilder) SetCollation(c *Collation) *AggregateOptionsBuilder {
ao.Opts = append(ao.Opts, func(opts *AggregateOptions) error {
Expand All @@ -99,8 +97,7 @@ func (ao *AggregateOptionsBuilder) SetCollation(c *Collation) *AggregateOptionsB
}

// SetMaxAwaitTime sets the value for the MaxAwaitTime field. Specifies maximum amount of time
// that the server should wait for new documents to satisfy a tailable cursor query. This option is
// only valid for MongoDB versions >= 3.2 and is ignored for previous server versions.
// that the server should wait for new documents to satisfy a tailable cursor query.
func (ao *AggregateOptionsBuilder) SetMaxAwaitTime(d time.Duration) *AggregateOptionsBuilder {
ao.Opts = append(ao.Opts, func(opts *AggregateOptions) error {
opts.MaxAwaitTime = &d
Expand Down
3 changes: 1 addition & 2 deletions mongo/options/bulkwriteoptions.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,7 @@ func (b *BulkWriteOptionsBuilder) SetOrdered(ordered bool) *BulkWriteOptionsBuil
}

// SetBypassDocumentValidation sets the value for the BypassDocumentValidation field. If true, writes
// executed as part of the operation will opt out of document-level validation on the server. This option
// is valid for MongoDB versions >= 3.2 and is ignored for previous server versions. The default value is
// executed as part of the operation will opt out of document-level validation on the server. The default value is
// false. See https://www.mongodb.com/docs/manual/core/schema-validation/ for more information about document
// validation.
func (b *BulkWriteOptionsBuilder) SetBypassDocumentValidation(bypass bool) *BulkWriteOptionsBuilder {
Expand Down
7 changes: 3 additions & 4 deletions mongo/options/changestreamoptions.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,9 @@ func (cso *ChangeStreamOptionsBuilder) SetBatchSize(i int32) *ChangeStreamOption
return cso
}

// SetCollation sets the value for the Collation field. Specifies a collation to use for string comparisons
// during the operation. This option is only valid for MongoDB versions >= 3.4. For previous server versions,
// the driver will return an error if this option is used. The default value is nil, which means the default
// collation of the collection will be used.
// SetCollation sets the value for the Collation field. Specifies a collation to
// use for string comparisons during the operation. The default value is nil,
// which means the default collation of the collection will be used.
func (cso *ChangeStreamOptionsBuilder) SetCollation(c Collation) *ChangeStreamOptionsBuilder {
cso.Opts = append(cso.Opts, func(opts *ChangeStreamOptions) error {
opts.Collation = &c
Expand Down
11 changes: 5 additions & 6 deletions mongo/options/clientoptions.go
Original file line number Diff line number Diff line change
Expand Up @@ -662,9 +662,9 @@ func (c *ClientOptions) SetAuth(auth Credential) *ClientOptions {

// SetCompressors sets the compressors that can be used when communicating with a server. Valid values are:
//
// 1. "snappy" - requires server version >= 3.4
// 1. "snappy"
//
// 2. "zlib" - requires server version >= 3.6
// 2. "zlib"
//
// 3. "zstd" - requires server version >= 4.2, and driver version >= 1.2.0 with cgo support enabled or driver
// version >= 1.3.0 without cgo.
Expand Down Expand Up @@ -896,9 +896,8 @@ func (c *ClientOptions) SetReplicaSet(s string) *ClientOptions {
// DeleteManyModel instances to be considered retryable. Unacknowledged writes will not be retried, even if this option
// is set to true.
//
// This option requires server version >= 3.6 and a replica set or sharded cluster and will be ignored for any other
// cluster type. This can also be set through the "retryWrites" URI option (e.g. "retryWrites=true"). The default is
// true.
// This option only works on a replica set or sharded cluster and will be ignored for any other cluster type.
// This can also be set through the "retryWrites" URI option (e.g. "retryWrites=true"). The default is true.
func (c *ClientOptions) SetRetryWrites(b bool) *ClientOptions {
c.RetryWrites = &b

Expand All @@ -912,7 +911,7 @@ func (c *ClientOptions) SetRetryWrites(b bool) *ClientOptions {
// EstimatedDocumentCount, Watch (for Client, Database, and Collection), ListCollections, and ListDatabases. Note that
// operations run through RunCommand are not retried.
//
// This option requires server version >= 3.6 and driver version >= 1.1.0. The default is true.
// The default is true.
func (c *ClientOptions) SetRetryReads(b bool) *ClientOptions {
c.RetryReads = &b

Expand Down
7 changes: 3 additions & 4 deletions mongo/options/countoptions.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,9 @@ func (co *CountOptionsBuilder) List() []func(*CountOptions) error {
return co.Opts
}

// SetCollation sets the value for the Collation field. Specifies a collation to use for string comparisons
// during the operation. This option is only valid for MongoDB versions >= 3.4. For previous server versions,
// the driver will return an error if this option is used. The default value is nil, which means the default
// collation of the collection will be used.
// SetCollation sets the value for the Collation field. Specifies a collation to
// use for string comparisons during the operation. The default value is nil,
// which means the default collation of the collection will be used.
func (co *CountOptionsBuilder) SetCollation(c *Collation) *CountOptionsBuilder {
co.Opts = append(co.Opts, func(opts *CountOptions) error {
opts.Collation = c
Expand Down
Loading

0 comments on commit 725480c

Please sign in to comment.