diff --git a/.evergreen/config.yml b/.evergreen/config.yml index 04695353b6..19bdea0865 100644 --- a/.evergreen/config.yml +++ b/.evergreen/config.yml @@ -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: @@ -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"] } diff --git a/README.md b/README.md index f52d9a264c..089a5647cf 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/internal/driverutil/description.go b/internal/driverutil/description.go index df3adc3692..899637997f 100644 --- a/internal/driverutil/description.go +++ b/internal/driverutil/description.go @@ -21,7 +21,7 @@ import ( ) const ( - MinWireVersion = 6 + MinWireVersion = 7 MaxWireVersion = 25 ) diff --git a/internal/integration/causal_consistency_test.go b/internal/integration/causal_consistency_test.go index 2f997f956e..f4817334da 100644 --- a/internal/integration/causal_consistency_test.go +++ b/internal/integration/causal_consistency_test.go @@ -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() diff --git a/internal/integration/index_view_test.go b/internal/integration/index_view_test.go index 62625c777a..89ad63b988 100644 --- a/internal/integration/index_view_test.go +++ b/internal/integration/index_view_test.go @@ -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) diff --git a/mongo/bulk_write_models.go b/mongo/bulk_write_models.go index d4aff51625..264e041601 100644 --- a/mongo/bulk_write_models.go +++ b/mongo/bulk_write_models.go @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 diff --git a/mongo/database.go b/mongo/database.go index ebc574cbf4..973c127ca2 100644 --- a/mongo/database.go +++ b/mongo/database.go @@ -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 @@ -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. // diff --git a/mongo/options/aggregateoptions.go b/mongo/options/aggregateoptions.go index c49951dc44..cf419677dc 100644 --- a/mongo/options/aggregateoptions.go +++ b/mongo/options/aggregateoptions.go @@ -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 { @@ -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 { @@ -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 diff --git a/mongo/options/bulkwriteoptions.go b/mongo/options/bulkwriteoptions.go index 11dd6c1b7c..186e83a0c5 100644 --- a/mongo/options/bulkwriteoptions.go +++ b/mongo/options/bulkwriteoptions.go @@ -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 { diff --git a/mongo/options/changestreamoptions.go b/mongo/options/changestreamoptions.go index 66f1899faa..5607e10dd0 100644 --- a/mongo/options/changestreamoptions.go +++ b/mongo/options/changestreamoptions.go @@ -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 diff --git a/mongo/options/clientoptions.go b/mongo/options/clientoptions.go index 9623562ec8..8602bf2e80 100644 --- a/mongo/options/clientoptions.go +++ b/mongo/options/clientoptions.go @@ -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. @@ -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 @@ -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 diff --git a/mongo/options/countoptions.go b/mongo/options/countoptions.go index 8f92b62f73..27df828b00 100644 --- a/mongo/options/countoptions.go +++ b/mongo/options/countoptions.go @@ -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 diff --git a/mongo/options/createcollectionoptions.go b/mongo/options/createcollectionoptions.go index fd0aad57d0..d1231758f3 100644 --- a/mongo/options/createcollectionoptions.go +++ b/mongo/options/createcollectionoptions.go @@ -193,9 +193,8 @@ func (c *CreateCollectionOptionsBuilder) SetCapped(capped bool) *CreateCollectio return c } -// SetCollation sets the value for the Collation field. Specifies the default collation for the new -// collection. 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 the default +// collation for the new collection. The default value is nil. func (c *CreateCollectionOptionsBuilder) SetCollation(collation *Collation) *CreateCollectionOptionsBuilder { c.Opts = append(c.Opts, func(opts *CreateCollectionOptions) error { opts.Collation = collation @@ -222,9 +221,9 @@ func (c *CreateCollectionOptionsBuilder) SetChangeStreamPreAndPostImages(csppi i return c } -// SetDefaultIndexOptions sets the value for the DefaultIndexOptions field. Specifies a default -// configuration for indexes on the collection. This option is only valid for MongoDB versions -// >= 3.4. The default value is nil, meaning indexes will be configured using server defaults. +// SetDefaultIndexOptions sets the value for the DefaultIndexOptions field. +// Specifies a default configuration for indexes on the collection. The default +// value is nil, meaning indexes will be configured using server defaults. func (c *CreateCollectionOptionsBuilder) SetDefaultIndexOptions(iopts *DefaultIndexOptionsBuilder) *CreateCollectionOptionsBuilder { c.Opts = append(c.Opts, func(opts *CreateCollectionOptions) error { opts.DefaultIndexOptions = iopts @@ -278,7 +277,7 @@ func (c *CreateCollectionOptionsBuilder) SetStorageEngine(storageEngine interfac // SetValidationAction sets the value for the ValidationAction field. Specifies what should happen if a // document being inserted does not pass validation. Valid values are "error" and "warn". See // https://www.mongodb.com/docs/manual/core/schema-validation/#accept-or-reject-invalid-documents for more -// information. This option is only valid for MongoDB versions >= 3.2. The default value is "error". +// information. The default value is "error". func (c *CreateCollectionOptionsBuilder) SetValidationAction(action string) *CreateCollectionOptionsBuilder { c.Opts = append(c.Opts, func(opts *CreateCollectionOptions) error { opts.ValidationAction = &action @@ -292,7 +291,7 @@ func (c *CreateCollectionOptionsBuilder) SetValidationAction(action string) *Cre // SetValidationLevel sets the value for the ValidationLevel field. Specifies how strictly the server applies // validation rules to existing documents in the collection during update operations. Valid values are "off", // "strict", and "moderate". See https://www.mongodb.com/docs/manual/core/schema-validation/#existing-documents -// for more information. This option is only valid for MongoDB versions >= 3.2. The default value is "strict". +// for more information. The default value is "strict". func (c *CreateCollectionOptionsBuilder) SetValidationLevel(level string) *CreateCollectionOptionsBuilder { c.Opts = append(c.Opts, func(opts *CreateCollectionOptions) error { opts.ValidationLevel = &level @@ -305,8 +304,7 @@ func (c *CreateCollectionOptionsBuilder) SetValidationLevel(level string) *Creat // SetValidator sets the value for the Validator field. Sets a document specifying validation rules for the // collection. See https://www.mongodb.com/docs/manual/core/schema-validation/ for more information about -// schema validation. This option is only valid for MongoDB versions >= 3.2. The default value is nil, -// meaning no validator will be used for the collection. +// schema validation. The default value is nil, meaning no validator will be used for the collection. func (c *CreateCollectionOptionsBuilder) SetValidator(validator interface{}) *CreateCollectionOptionsBuilder { c.Opts = append(c.Opts, func(opts *CreateCollectionOptions) error { opts.Validator = validator @@ -402,9 +400,8 @@ func (c *CreateViewOptionsBuilder) List() []func(*CreateViewOptions) error { return c.Opts } -// SetCollation sets the value for the Collation field. Specifies the default collation for the new -// collection. 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 the default +// collation for the new collection. The default value is nil. func (c *CreateViewOptionsBuilder) SetCollation(collation *Collation) *CreateViewOptionsBuilder { c.Opts = append(c.Opts, func(opts *CreateViewOptions) error { opts.Collation = collation diff --git a/mongo/options/deleteoptions.go b/mongo/options/deleteoptions.go index f0d88043c0..1d045d9960 100644 --- a/mongo/options/deleteoptions.go +++ b/mongo/options/deleteoptions.go @@ -34,11 +34,9 @@ func (do *DeleteOneOptionsBuilder) List() []func(*DeleteOneOptions) error { return do.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 (do *DeleteOneOptionsBuilder) SetCollation(c *Collation) *DeleteOneOptionsBuilder { do.Opts = append(do.Opts, func(opts *DeleteOneOptions) error { opts.Collation = c @@ -62,13 +60,14 @@ func (do *DeleteOneOptionsBuilder) SetComment(comment interface{}) *DeleteOneOpt return do } -// SetHint sets the value for the Hint field. 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 sets the value for the Hint field. 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 (do *DeleteOneOptionsBuilder) SetHint(hint interface{}) *DeleteOneOptionsBuilder { do.Opts = append(do.Opts, func(opts *DeleteOneOptions) error { opts.Hint = hint @@ -122,10 +121,9 @@ func (do *DeleteManyOptionsBuilder) List() []func(*DeleteManyOptions) error { return do.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 (do *DeleteManyOptionsBuilder) SetCollation(c *Collation) *DeleteManyOptionsBuilder { do.Opts = append(do.Opts, func(opts *DeleteManyOptions) error { opts.Collation = c @@ -149,14 +147,14 @@ func (do *DeleteManyOptionsBuilder) SetComment(comment interface{}) *DeleteManyO return do } -// SetHint sets the value for the Hint field. 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 sets the value for the Hint field. 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 (do *DeleteManyOptionsBuilder) SetHint(hint interface{}) *DeleteManyOptionsBuilder { do.Opts = append(do.Opts, func(opts *DeleteManyOptions) error { opts.Hint = hint diff --git a/mongo/options/distinctoptions.go b/mongo/options/distinctoptions.go index 0b9167d5d0..3449ecee36 100644 --- a/mongo/options/distinctoptions.go +++ b/mongo/options/distinctoptions.go @@ -33,11 +33,9 @@ func (do *DistinctOptionsBuilder) List() []func(*DistinctOptions) error { return do.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 (do *DistinctOptionsBuilder) SetCollation(c *Collation) *DistinctOptionsBuilder { do.Opts = append(do.Opts, func(opts *DistinctOptions) error { opts.Collation = c diff --git a/mongo/options/findoptions.go b/mongo/options/findoptions.go index e036b9ed64..e94f8e019f 100644 --- a/mongo/options/findoptions.go +++ b/mongo/options/findoptions.go @@ -52,11 +52,11 @@ func (f *FindOptionsBuilder) List() []func(*FindOptions) error { return f.Opts } -// SetAllowDiskUse sets the value for the AllowDiskUse field. AllowDiskUse specifies whether the -// server can write temporary data to disk while executing the Find operation. This option is only -// valid for MongoDB versions >= 4.4. Server versions >= 3.2 will report an error if this option -// is specified. For server versions < 3.2, the driver will return a client-side error if this -// option is specified. The default value is false. +// SetAllowDiskUse sets the value for the AllowDiskUse field. AllowDiskUse +// specifies whether the server can write temporary data to disk while executing +// the Find operation. This option is only valid for MongoDB versions >= 4.4. +// Server versions < 4.4 will return an error if this option is specified. The +// default value is false. func (f *FindOptionsBuilder) SetAllowDiskUse(b bool) *FindOptionsBuilder { f.Opts = append(f.Opts, func(opts *FindOptions) error { opts.AllowDiskUse = &b @@ -86,10 +86,10 @@ func (f *FindOptionsBuilder) SetBatchSize(i int32) *FindOptionsBuilder { return f } -// SetCollation sets the value for the Collation field. Collation 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. Collation 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 (f *FindOptionsBuilder) SetCollation(collation *Collation) *FindOptionsBuilder { f.Opts = append(f.Opts, func(opts *FindOptions) error { opts.Collation = collation @@ -167,11 +167,11 @@ func (f *FindOptionsBuilder) SetMax(max interface{}) *FindOptionsBuilder { return f } -// SetMaxAwaitTime sets the value for the MaxAwaitTime field. MaxAwaitTime is the maximum amount of -// time that the server should wait for new documents to satisfy a tailable cursor query. This -// option is only valid for tailable await cursors (see the CursorType option for more information) -// and MongoDB versions >= 3.2. For other cursor types or previous server versions, this option -// is ignored. +// SetMaxAwaitTime sets the value for the MaxAwaitTime field. MaxAwaitTime is +// the maximum amount of time that the server should wait for new documents to +// satisfy a tailable cursor query. This option is only valid for tailable await +// cursors (see the CursorType option for more information). For other cursor +// types, this option is ignored. func (f *FindOptionsBuilder) SetMaxAwaitTime(d time.Duration) *FindOptionsBuilder { f.Opts = append(f.Opts, func(opts *FindOptions) error { opts.MaxAwaitTime = &d @@ -314,10 +314,9 @@ func (f *FindOneOptionsBuilder) SetAllowPartialResults(b bool) *FindOneOptionsBu return f } -// 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 (f *FindOneOptionsBuilder) SetCollation(collation *Collation) *FindOneOptionsBuilder { f.Opts = append(f.Opts, func(opts *FindOneOptions) error { opts.Collation = collation @@ -470,8 +469,7 @@ func (f *FindOneAndReplaceOptionsBuilder) List() []func(*FindOneAndReplaceOption } // 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 +// 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 (f *FindOneAndReplaceOptionsBuilder) SetBypassDocumentValidation(b bool) *FindOneAndReplaceOptionsBuilder { @@ -484,10 +482,9 @@ func (f *FindOneAndReplaceOptionsBuilder) SetBypassDocumentValidation(b bool) *F return f } -// 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 (f *FindOneAndReplaceOptionsBuilder) SetCollation(collation *Collation) *FindOneAndReplaceOptionsBuilder { f.Opts = append(f.Opts, func(opts *FindOneAndReplaceOptions) error { opts.Collation = collation @@ -631,11 +628,10 @@ func (f *FindOneAndUpdateOptionsBuilder) List() []func(*FindOneAndUpdateOptions) return f.Opts } -// SetArrayFilters sets the value for the ArrayFilters field. ArrayFilters is a set of filters -// specifying to which array elements an update should apply. This option is only valid for -// MongoDB versions >= 3.6. For previous server versions, the driver will return an error if -// this option is used. The default value is nil, which means the update will apply to all -// array elements. +// SetArrayFilters sets the value for the ArrayFilters field. ArrayFilters is a +// set of filters specifying to which array elements an update should apply. The +// default value is nil, which means the update will apply to all array +// elements. func (f *FindOneAndUpdateOptionsBuilder) SetArrayFilters(filters []interface{}) *FindOneAndUpdateOptionsBuilder { f.Opts = append(f.Opts, func(opts *FindOneAndUpdateOptions) error { opts.ArrayFilters = filters @@ -648,7 +644,6 @@ func (f *FindOneAndUpdateOptionsBuilder) SetArrayFilters(filters []interface{}) // 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 false. See https://www.mongodb.com/docs/manual/core/schema-validation/ // for more information about document validation. func (f *FindOneAndUpdateOptionsBuilder) SetBypassDocumentValidation(b bool) *FindOneAndUpdateOptionsBuilder { @@ -661,10 +656,9 @@ func (f *FindOneAndUpdateOptionsBuilder) SetBypassDocumentValidation(b bool) *Fi return f } -// 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 (f *FindOneAndUpdateOptionsBuilder) SetCollation(collation *Collation) *FindOneAndUpdateOptionsBuilder { f.Opts = append(f.Opts, func(opts *FindOneAndUpdateOptions) error { opts.Collation = collation @@ -804,10 +798,9 @@ func (f *FindOneAndDeleteOptionsBuilder) List() []func(*FindOneAndDeleteOptions) return f.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 (f *FindOneAndDeleteOptionsBuilder) SetCollation(collation *Collation) *FindOneAndDeleteOptionsBuilder { f.Opts = append(f.Opts, func(opts *FindOneAndDeleteOptions) error { opts.Collation = collation diff --git a/mongo/options/indexoptions.go b/mongo/options/indexoptions.go index 48ddac0b63..b7b61c2edf 100644 --- a/mongo/options/indexoptions.go +++ b/mongo/options/indexoptions.go @@ -262,8 +262,7 @@ func (i *IndexOptionsBuilder) SetSparse(sparse bool) *IndexOptionsBuilder { // SetStorageEngine sets the value for the StorageEngine field. Specifies the // storage engine to use for the index. The value must be a document in the form // {: }. The default value is nil, which means that -// the default storage engine will be used. This option is only applicable for -// MongoDB versions >= 3.0 and is ignored for previous server versions. +// the default storage engine will be used. func (i *IndexOptionsBuilder) SetStorageEngine(engine interface{}) *IndexOptionsBuilder { i.Opts = append(i.Opts, func(opts *IndexOptions) error { opts.StorageEngine = engine @@ -424,8 +423,7 @@ func (i *IndexOptionsBuilder) SetBucketSize(bucketSize int32) *IndexOptionsBuild } // SetPartialFilterExpression sets the value for the PartialFilterExpression field. Sets -// a document that defines which collection documents the index should reference. This -// option is only valid for MongoDB versions >= 3.2 and is ignored for previous server versions. +// a document that defines which collection documents the index should reference. func (i *IndexOptionsBuilder) SetPartialFilterExpression(expression interface{}) *IndexOptionsBuilder { i.Opts = append(i.Opts, func(opts *IndexOptions) error { opts.PartialFilterExpression = expression @@ -437,8 +435,7 @@ func (i *IndexOptionsBuilder) SetPartialFilterExpression(expression interface{}) } // SetCollation sets the value for the Collation field. Specifies the collation to use for -// string comparisons for the index. 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. +// string comparisons for the index. func (i *IndexOptionsBuilder) SetCollation(collation *Collation) *IndexOptionsBuilder { i.Opts = append(i.Opts, func(opts *IndexOptions) error { opts.Collation = collation diff --git a/mongo/options/insertoptions.go b/mongo/options/insertoptions.go index 43b87470b9..61745600a9 100644 --- a/mongo/options/insertoptions.go +++ b/mongo/options/insertoptions.go @@ -33,8 +33,7 @@ func (ioo *InsertOneOptionsBuilder) List() []func(*InsertOneOptions) error { // 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 false. See https://www.mongodb.com/docs/manual/core/schema-validation/ +// server. The default value is false. See https://www.mongodb.com/docs/manual/core/schema-validation/ // for more information about document validation. func (ioo *InsertOneOptionsBuilder) SetBypassDocumentValidation(b bool) *InsertOneOptionsBuilder { ioo.Opts = append(ioo.Opts, func(opts *InsertOneOptions) error { @@ -86,8 +85,7 @@ func (imo *InsertManyOptionsBuilder) List() []func(*InsertManyOptions) error { // 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 false. See https://www.mongodb.com/docs/manual/core/schema-validation/ +// server. The default value is false. See https://www.mongodb.com/docs/manual/core/schema-validation/ // for more information about document validation. func (imo *InsertManyOptionsBuilder) SetBypassDocumentValidation(b bool) *InsertManyOptionsBuilder { imo.Opts = append(imo.Opts, func(opts *InsertManyOptions) error { diff --git a/mongo/options/replaceoptions.go b/mongo/options/replaceoptions.go index d50cf04a15..ee918f1ffe 100644 --- a/mongo/options/replaceoptions.go +++ b/mongo/options/replaceoptions.go @@ -39,7 +39,6 @@ func (ro *ReplaceOptionsBuilder) List() []func(*ReplaceOptions) error { // 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 false. See https://www.mongodb.com/docs/manual/core/schema-validation/ for // more information about document validation. func (ro *ReplaceOptionsBuilder) SetBypassDocumentValidation(b bool) *ReplaceOptionsBuilder { @@ -52,10 +51,9 @@ func (ro *ReplaceOptionsBuilder) SetBypassDocumentValidation(b bool) *ReplaceOpt return ro } -// 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 (ro *ReplaceOptionsBuilder) SetCollation(c *Collation) *ReplaceOptionsBuilder { ro.Opts = append(ro.Opts, func(opts *ReplaceOptions) error { opts.Collation = c @@ -79,14 +77,14 @@ func (ro *ReplaceOptionsBuilder) SetComment(comment interface{}) *ReplaceOptions return ro } -// SetHint sets the value for the Hint field. 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 sets the value for the Hint field. 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 (ro *ReplaceOptionsBuilder) SetHint(h interface{}) *ReplaceOptionsBuilder { ro.Opts = append(ro.Opts, func(opts *ReplaceOptions) error { opts.Hint = h diff --git a/mongo/options/updateoptions.go b/mongo/options/updateoptions.go index 5f16c10869..1deb1b8287 100644 --- a/mongo/options/updateoptions.go +++ b/mongo/options/updateoptions.go @@ -38,10 +38,10 @@ func (uo *UpdateOneOptionsBuilder) List() []func(*UpdateOneOptions) error { return uo.Opts } -// SetArrayFilters sets the value for the ArrayFilters field. ArrayFilters is a set of filters -// specifying to which array elements an update should apply. This option is only valid for MongoDB -// versions >= 3.6. For previous server versions, the driver will return an error if this option is -// used. The default value is nil, which means the update will apply to all array elements. +// SetArrayFilters sets the value for the ArrayFilters field. ArrayFilters is a +// set of filters specifying to which array elements an update should apply. The +// default value is nil, which means the update will apply to all array +// elements. func (uo *UpdateOneOptionsBuilder) SetArrayFilters(af []interface{}) *UpdateOneOptionsBuilder { uo.Opts = append(uo.Opts, func(opts *UpdateOneOptions) error { opts.ArrayFilters = af @@ -54,7 +54,6 @@ func (uo *UpdateOneOptionsBuilder) SetArrayFilters(af []interface{}) *UpdateOneO // 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 false. See https://www.mongodb.com/docs/manual/core/schema-validation/ for // more information about document validation. func (uo *UpdateOneOptionsBuilder) SetBypassDocumentValidation(b bool) *UpdateOneOptionsBuilder { @@ -67,10 +66,9 @@ func (uo *UpdateOneOptionsBuilder) SetBypassDocumentValidation(b bool) *UpdateOn return uo } -// 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 (uo *UpdateOneOptionsBuilder) SetCollation(c *Collation) *UpdateOneOptionsBuilder { uo.Opts = append(uo.Opts, func(opts *UpdateOneOptions) error { opts.Collation = c @@ -94,13 +92,14 @@ func (uo *UpdateOneOptionsBuilder) SetComment(comment interface{}) *UpdateOneOpt return uo } -// SetHint sets the value for the Hint field. 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 sets the value for the Hint field. 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 (uo *UpdateOneOptionsBuilder) SetHint(h interface{}) *UpdateOneOptionsBuilder { uo.Opts = append(uo.Opts, func(opts *UpdateOneOptions) error { opts.Hint = h @@ -184,10 +183,10 @@ func (uo *UpdateManyOptionsBuilder) List() []func(*UpdateManyOptions) error { return uo.Opts } -// SetArrayFilters sets the value for the ArrayFilters field. ArrayFilters is a set of filters -// specifying to which array elements an update should apply. This option is only valid for MongoDB -// versions >= 3.6. For previous server versions, the driver will return an error if this option is -// used. The default value is nil, which means the update will apply to all array elements. +// SetArrayFilters sets the value for the ArrayFilters field. ArrayFilters is a +// set of filters specifying to which array elements an update should apply. The +// default value is nil, which means the update will apply to all array +// elements. func (uo *UpdateManyOptionsBuilder) SetArrayFilters(af []interface{}) *UpdateManyOptionsBuilder { uo.Opts = append(uo.Opts, func(opts *UpdateManyOptions) error { opts.ArrayFilters = af @@ -200,7 +199,6 @@ func (uo *UpdateManyOptionsBuilder) SetArrayFilters(af []interface{}) *UpdateMan // 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 false. See https://www.mongodb.com/docs/manual/core/schema-validation/ for // more information about document validation. func (uo *UpdateManyOptionsBuilder) SetBypassDocumentValidation(b bool) *UpdateManyOptionsBuilder { @@ -213,10 +211,9 @@ func (uo *UpdateManyOptionsBuilder) SetBypassDocumentValidation(b bool) *UpdateM return uo } -// 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 (uo *UpdateManyOptionsBuilder) SetCollation(c *Collation) *UpdateManyOptionsBuilder { uo.Opts = append(uo.Opts, func(opts *UpdateManyOptions) error { opts.Collation = c @@ -240,13 +237,14 @@ func (uo *UpdateManyOptionsBuilder) SetComment(comment interface{}) *UpdateManyO return uo } -// SetHint sets the value for the Hint field. 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 sets the value for the Hint field. 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 (uo *UpdateManyOptionsBuilder) SetHint(h interface{}) *UpdateManyOptionsBuilder { uo.Opts = append(uo.Opts, func(opts *UpdateManyOptions) error { opts.Hint = h diff --git a/mongo/results.go b/mongo/results.go index d8407ef5c0..0a10dbaffe 100644 --- a/mongo/results.go +++ b/mongo/results.go @@ -220,11 +220,10 @@ type CollectionSpecification struct { // The type of the collection. This will either be "collection" or "view". Type string - // Whether or not the collection is readOnly. This will be false for MongoDB versions < 3.4. + // Whether or not the collection is readOnly. ReadOnly bool - // The collection UUID. This field will be nil for MongoDB versions < 3.6. For versions 3.6 and higher, this will - // be a bson.Binary with Subtype 4. + // The collection UUID as a bson.Binary with subtype 4. UUID *bson.Binary // A document containing the options used to construct the collection. diff --git a/testdata/server-discovery-and-monitoring/monitoring/discovered_standalone.json b/testdata/server-discovery-and-monitoring/monitoring/discovered_standalone.json index caf31b3391..dd8f7fc51e 100644 --- a/testdata/server-discovery-and-monitoring/monitoring/discovered_standalone.json +++ b/testdata/server-discovery-and-monitoring/monitoring/discovered_standalone.json @@ -11,7 +11,7 @@ "helloOk": true, "isWritablePrimary": true, "minWireVersion": 0, - "maxWireVersion": 4 + "maxWireVersion": 6 } ] ], diff --git a/testdata/server-discovery-and-monitoring/monitoring/discovered_standalone.yml b/testdata/server-discovery-and-monitoring/monitoring/discovered_standalone.yml index 0ad4462b9c..5d808f2600 100644 --- a/testdata/server-discovery-and-monitoring/monitoring/discovered_standalone.yml +++ b/testdata/server-discovery-and-monitoring/monitoring/discovered_standalone.yml @@ -5,7 +5,7 @@ phases: responses: - - "a:27017" - - { ok: 1, helloOk: true, isWritablePrimary: true, minWireVersion: 0, maxWireVersion: 4 } + - { ok: 1, helloOk: true, isWritablePrimary: true, minWireVersion: 0, maxWireVersion: 6 } outcome: events: diff --git a/testdata/server-discovery-and-monitoring/monitoring/replica_set_with_no_primary.yml b/testdata/server-discovery-and-monitoring/monitoring/replica_set_with_no_primary.yml index 6bb40e9bdf..ce9cdf46e6 100644 --- a/testdata/server-discovery-and-monitoring/monitoring/replica_set_with_no_primary.yml +++ b/testdata/server-discovery-and-monitoring/monitoring/replica_set_with_no_primary.yml @@ -110,4 +110,3 @@ phases: hosts: [] passives: [] type: "PossiblePrimary" - diff --git a/testdata/server-discovery-and-monitoring/monitoring/replica_set_with_primary.yml b/testdata/server-discovery-and-monitoring/monitoring/replica_set_with_primary.yml index 8855585ca5..2c78919063 100644 --- a/testdata/server-discovery-and-monitoring/monitoring/replica_set_with_primary.yml +++ b/testdata/server-discovery-and-monitoring/monitoring/replica_set_with_primary.yml @@ -109,4 +109,3 @@ phases: hosts: [] passives: [] type: "Unknown" - diff --git a/testdata/server-discovery-and-monitoring/monitoring/standalone_suppress_equal_description_changes.yml b/testdata/server-discovery-and-monitoring/monitoring/standalone_suppress_equal_description_changes.yml index 00c2e770b9..f2f83ffbac 100644 --- a/testdata/server-discovery-and-monitoring/monitoring/standalone_suppress_equal_description_changes.yml +++ b/testdata/server-discovery-and-monitoring/monitoring/standalone_suppress_equal_description_changes.yml @@ -5,10 +5,10 @@ phases: responses: - - "a:27017" - - { ok: 1, helloOk: true, isWritablePrimary: true, minWireVersion: 0, maxWireVersion: 4 } + - { ok: 1, helloOk: true, isWritablePrimary: true, minWireVersion: 0, maxWireVersion: 6 } - - "a:27017" - - { ok: 1, helloOk: true, isWritablePrimary: true, minWireVersion: 0, maxWireVersion: 4 } + - { ok: 1, helloOk: true, isWritablePrimary: true, minWireVersion: 0, maxWireVersion: 6 } outcome: events: diff --git a/testdata/server-discovery-and-monitoring/rs/compatible.json b/testdata/server-discovery-and-monitoring/rs/compatible.json index 444b13e9d5..dfd5d57dfa 100644 --- a/testdata/server-discovery-and-monitoring/rs/compatible.json +++ b/testdata/server-discovery-and-monitoring/rs/compatible.json @@ -16,7 +16,7 @@ "b:27017" ], "minWireVersion": 0, - "maxWireVersion": 6 + "maxWireVersion": 21 } ], [ diff --git a/testdata/server-discovery-and-monitoring/rs/compatible.yml b/testdata/server-discovery-and-monitoring/rs/compatible.yml index 8b5d9f456a..ce17d7e302 100644 --- a/testdata/server-discovery-and-monitoring/rs/compatible.yml +++ b/testdata/server-discovery-and-monitoring/rs/compatible.yml @@ -12,7 +12,7 @@ phases: [ setName: "rs", hosts: ["a:27017", "b:27017"], minWireVersion: 0, - maxWireVersion: 6 + maxWireVersion: 21 }], ["b:27017", { ok: 1, diff --git a/testdata/server-discovery-and-monitoring/rs/compatible_unknown.json b/testdata/server-discovery-and-monitoring/rs/compatible_unknown.json index cf92dd1ed3..95e03ea958 100644 --- a/testdata/server-discovery-and-monitoring/rs/compatible_unknown.json +++ b/testdata/server-discovery-and-monitoring/rs/compatible_unknown.json @@ -16,7 +16,7 @@ "b:27017" ], "minWireVersion": 0, - "maxWireVersion": 6 + "maxWireVersion": 21 } ] ], diff --git a/testdata/server-discovery-and-monitoring/rs/compatible_unknown.yml b/testdata/server-discovery-and-monitoring/rs/compatible_unknown.yml index 643e849819..ed97ab31ac 100644 --- a/testdata/server-discovery-and-monitoring/rs/compatible_unknown.yml +++ b/testdata/server-discovery-and-monitoring/rs/compatible_unknown.yml @@ -12,7 +12,7 @@ phases: [ setName: "rs", hosts: ["a:27017", "b:27017"], minWireVersion: 0, - maxWireVersion: 6 + maxWireVersion: 21 }], ], outcome: { diff --git a/testdata/server-discovery-and-monitoring/rs/secondary_ignore_ok_0.json b/testdata/server-discovery-and-monitoring/rs/secondary_ignore_ok_0.json index 4c1cb011a5..ee9519930b 100644 --- a/testdata/server-discovery-and-monitoring/rs/secondary_ignore_ok_0.json +++ b/testdata/server-discovery-and-monitoring/rs/secondary_ignore_ok_0.json @@ -1,5 +1,5 @@ { - "description": "New primary", + "description": "Secondary ignored when ok is zero", "uri": "mongodb://a,b/?replicaSet=rs", "phases": [ { diff --git a/testdata/server-discovery-and-monitoring/rs/secondary_ignore_ok_0.yml b/testdata/server-discovery-and-monitoring/rs/secondary_ignore_ok_0.yml index c7e605d662..d94fafaf99 100644 --- a/testdata/server-discovery-and-monitoring/rs/secondary_ignore_ok_0.yml +++ b/testdata/server-discovery-and-monitoring/rs/secondary_ignore_ok_0.yml @@ -1,4 +1,4 @@ -description: "New primary" +description: "Secondary ignored when ok is zero" uri: "mongodb://a,b/?replicaSet=rs" diff --git a/testdata/server-discovery-and-monitoring/rs/too_old.json b/testdata/server-discovery-and-monitoring/rs/too_old.json index c572b36680..461d00acc4 100644 --- a/testdata/server-discovery-and-monitoring/rs/too_old.json +++ b/testdata/server-discovery-and-monitoring/rs/too_old.json @@ -30,9 +30,7 @@ "hosts": [ "a:27017", "b:27017" - ], - "minWireVersion": 999, - "maxWireVersion": 1000 + ] } ] ], diff --git a/testdata/server-discovery-and-monitoring/rs/too_old.yml b/testdata/server-discovery-and-monitoring/rs/too_old.yml index 6235ac8d6d..ab238dbab9 100644 --- a/testdata/server-discovery-and-monitoring/rs/too_old.yml +++ b/testdata/server-discovery-and-monitoring/rs/too_old.yml @@ -18,9 +18,7 @@ phases: [ isWritablePrimary: false, secondary: true, setName: "rs", - hosts: ["a:27017", "b:27017"], - minWireVersion: 999, - maxWireVersion: 1000 + hosts: ["a:27017", "b:27017"] }] ], outcome: { diff --git a/testdata/server-discovery-and-monitoring/sharded/compatible.json b/testdata/server-discovery-and-monitoring/sharded/compatible.json index e531db97f9..ceb0ec24c4 100644 --- a/testdata/server-discovery-and-monitoring/sharded/compatible.json +++ b/testdata/server-discovery-and-monitoring/sharded/compatible.json @@ -23,7 +23,7 @@ "isWritablePrimary": true, "msg": "isdbgrid", "minWireVersion": 0, - "maxWireVersion": 6 + "maxWireVersion": 21 } ] ], diff --git a/testdata/server-discovery-and-monitoring/sharded/compatible.yml b/testdata/server-discovery-and-monitoring/sharded/compatible.yml index 06d5182a5c..20519089f5 100644 --- a/testdata/server-discovery-and-monitoring/sharded/compatible.yml +++ b/testdata/server-discovery-and-monitoring/sharded/compatible.yml @@ -17,7 +17,7 @@ phases: [ isWritablePrimary: true, msg: "isdbgrid", minWireVersion: 0, - maxWireVersion: 6 + maxWireVersion: 21 }] ], outcome: { diff --git a/testdata/server-discovery-and-monitoring/sharded/too_new.json b/testdata/server-discovery-and-monitoring/sharded/too_new.json index c4e984ddec..4b997d2163 100644 --- a/testdata/server-discovery-and-monitoring/sharded/too_new.json +++ b/testdata/server-discovery-and-monitoring/sharded/too_new.json @@ -21,9 +21,7 @@ "ok": 1, "helloOk": true, "isWritablePrimary": true, - "msg": "isdbgrid", - "minWireVersion": 7, - "maxWireVersion": 900 + "msg": "isdbgrid" } ] ], diff --git a/testdata/server-discovery-and-monitoring/sharded/too_new.yml b/testdata/server-discovery-and-monitoring/sharded/too_new.yml index 03032a4948..7d59cb4305 100644 --- a/testdata/server-discovery-and-monitoring/sharded/too_new.yml +++ b/testdata/server-discovery-and-monitoring/sharded/too_new.yml @@ -15,9 +15,7 @@ phases: [ ok: 1, helloOk: true, isWritablePrimary: true, - msg: "isdbgrid", - minWireVersion: 7, - maxWireVersion: 900 + msg: "isdbgrid" }] ], outcome: { diff --git a/testdata/server-discovery-and-monitoring/single/compatible.json b/testdata/server-discovery-and-monitoring/single/compatible.json index 302927598c..493d9b748e 100644 --- a/testdata/server-discovery-and-monitoring/single/compatible.json +++ b/testdata/server-discovery-and-monitoring/single/compatible.json @@ -11,7 +11,7 @@ "helloOk": true, "isWritablePrimary": true, "minWireVersion": 0, - "maxWireVersion": 6 + "maxWireVersion": 21 } ] ], diff --git a/testdata/server-discovery-and-monitoring/single/compatible.yml b/testdata/server-discovery-and-monitoring/single/compatible.yml index b84c1388c3..e183c7127d 100644 --- a/testdata/server-discovery-and-monitoring/single/compatible.yml +++ b/testdata/server-discovery-and-monitoring/single/compatible.yml @@ -8,7 +8,7 @@ phases: [ helloOk: true, isWritablePrimary: true, minWireVersion: 0, - maxWireVersion: 6 + maxWireVersion: 21 }] ], outcome: { diff --git a/testdata/server-discovery-and-monitoring/single/too_old_then_upgraded.json b/testdata/server-discovery-and-monitoring/single/too_old_then_upgraded.json index 58ae7d9de4..c3dd98cf62 100644 --- a/testdata/server-discovery-and-monitoring/single/too_old_then_upgraded.json +++ b/testdata/server-discovery-and-monitoring/single/too_old_then_upgraded.json @@ -1,5 +1,5 @@ { - "description": "Standalone with default maxWireVersion of 0 is upgraded to one with maxWireVersion 6", + "description": "Standalone with default maxWireVersion of 0 is upgraded to one with maxWireVersion 21", "uri": "mongodb://a", "phases": [ { @@ -35,7 +35,7 @@ "helloOk": true, "isWritablePrimary": true, "minWireVersion": 0, - "maxWireVersion": 6 + "maxWireVersion": 21 } ] ], diff --git a/testdata/server-discovery-and-monitoring/single/too_old_then_upgraded.yml b/testdata/server-discovery-and-monitoring/single/too_old_then_upgraded.yml index aed6bae6e0..87b72b9000 100644 --- a/testdata/server-discovery-and-monitoring/single/too_old_then_upgraded.yml +++ b/testdata/server-discovery-and-monitoring/single/too_old_then_upgraded.yml @@ -1,4 +1,4 @@ -description: "Standalone with default maxWireVersion of 0 is upgraded to one with maxWireVersion 6" +description: "Standalone with default maxWireVersion of 0 is upgraded to one with maxWireVersion 21" uri: "mongodb://a" phases: [ { @@ -29,7 +29,7 @@ phases: [ helloOk: true, isWritablePrimary: true, minWireVersion: 0, - maxWireVersion: 6 + maxWireVersion: 21 }] ], outcome: { diff --git a/testdata/server-discovery-and-monitoring/unified/hello-timeout.yml b/testdata/server-discovery-and-monitoring/unified/hello-timeout.yml new file mode 100644 index 0000000000..2a3374d1e7 --- /dev/null +++ b/testdata/server-discovery-and-monitoring/unified/hello-timeout.yml @@ -0,0 +1,318 @@ +--- +description: hello-timeout + +schemaVersion: "1.4" + +runOnRequirements: + # failCommand appName requirements + - minServerVersion: "4.4" + serverless: forbid + topologies: [ single, replicaset, sharded ] + +createEntities: + - client: + id: &setupClient setupClient + useMultipleMongoses: false + +initialData: &initialData + - collectionName: &collectionName hello-timeout + databaseName: &databaseName sdam-tests + documents: [] + +tests: + - description: Network timeout on Monitor handshake + operations: + # Configure the initial handshake to fail with a timeout. + # Use times: 2 so that the RTT hello is blocked as well. + - name: failPoint + object: testRunner + arguments: + client: *setupClient + failPoint: + configureFailPoint: failCommand + mode: + times: 2 + data: + failCommands: + - hello + - isMaster + appName: timeoutMonitorHandshakeTest + blockConnection: true + blockTimeMS: 1000 + - name: createEntities + object: testRunner + arguments: + entities: + - client: + id: &client client + useMultipleMongoses: false + observeEvents: + - commandStartedEvent + - serverDescriptionChangedEvent + - poolClearedEvent + uriOptions: + retryWrites: false + connectTimeoutMS: 250 + heartbeatFrequencyMS: 500 + appname: timeoutMonitorHandshakeTest + - database: + id: &database database + client: *client + databaseName: *databaseName + - collection: + id: &collection collection + database: *database + collectionName: *collectionName + # The network error on the initial handshake should mark the server + # Unknown (emitting a ServerDescriptionChangedEvent) and clear the pool. + - name: waitForEvent + object: testRunner + arguments: + client: *client + event: + serverDescriptionChangedEvent: + newDescription: + type: Unknown + count: 1 + # Perform an operation to ensure the node is discovered. + - name: insertMany + object: *collection + arguments: + documents: + - _id: 1 + - _id: 2 + # We cannot assert the server was marked Unknown and pool was cleared an + # exact number of times because the RTT hello may or may not have + # triggered this failpoint as well. + # - name: assertEventCount + # object: testRunner + # arguments: + # event: ServerMarkedUnknownEvent + # count: 1 + # - name: assertEventCount + # object: testRunner + # arguments: + # event: PoolClearedEvent + # count: 1 + expectEvents: + - client: *client + eventType: command + events: + - commandStartedEvent: + command: + insert: hello-timeout + documents: + - _id: 1 + - _id: 2 + commandName: insert + databaseName: *databaseName + outcome: + - collectionName: *collectionName + databaseName: *databaseName + documents: + - _id: 1 + - _id: 2 + + - description: Network timeout on Monitor check + operations: + - name: createEntities + object: testRunner + arguments: + entities: + - client: + id: &client client + useMultipleMongoses: false + observeEvents: + - commandStartedEvent + - serverDescriptionChangedEvent + - poolClearedEvent + uriOptions: + retryWrites: false + connectTimeoutMS: 750 + heartbeatFrequencyMS: 500 + appname: timeoutMonitorCheckTest + - database: + id: &database database + client: *client + databaseName: *databaseName + - collection: + id: &collection collection + database: *database + collectionName: *collectionName + # Perform an operation to ensure the node is discovered. + - name: insertMany + object: *collection + arguments: + documents: + - _id: 1 + - _id: 2 + # Configure the next streaming hello check to fail with a timeout. + # Use "times: 4" to increase the probability that the Monitor check times + # out since the RTT hello may trigger this failpoint one or many times as + # well. + - name: failPoint + object: testRunner + arguments: + failPoint: + configureFailPoint: failCommand + mode: + times: 4 + data: + failCommands: + - hello + - isMaster + appName: timeoutMonitorCheckTest + blockConnection: true + # blockTimeMS is evaluated after the waiting for heartbeatFrequencyMS server-side, so this value only + # needs to be greater than connectTimeoutMS. The driver will wait for (500+750)ms and the server will + # respond after (500+1000)ms. + blockTimeMS: 1000 + client: *setupClient + - name: waitForEvent + object: testRunner + arguments: + client: *client + event: + serverDescriptionChangedEvent: + newDescription: + type: Unknown + count: 1 + # The network error on the next check should mark the server Unknown and + # clear the pool. + - name: waitForEvent + object: testRunner + arguments: + client: *client + event: + poolClearedEvent: {} + count: 1 + # Perform an operation to ensure the node is rediscovered. + - name: insertMany + object: *collection + arguments: + documents: + - _id: 3 + - _id: 4 + # We cannot assert the server was marked Unknown and pool was cleared an + # exact number of times because the RTT hello may have triggered this + # failpoint one or many times as well. + + expectEvents: + - client: *client + eventType: command + events: + - commandStartedEvent: + command: + insert: hello-timeout + documents: + - _id: 1 + - _id: 2 + commandName: insert + databaseName: *databaseName + - commandStartedEvent: + command: + insert: hello-timeout + documents: + - _id: 3 + - _id: 4 + commandName: insert + databaseName: *databaseName + outcome: + - collectionName: *collectionName + databaseName: *databaseName + documents: + - _id: 1 + - _id: 2 + - _id: 3 + - _id: 4 + + - description: Driver extends timeout while streaming + operations: + - name: createEntities + object: testRunner + arguments: + entities: + - client: + id: &client client + observeEvents: + - commandStartedEvent + - serverDescriptionChangedEvent + - poolClearedEvent + uriOptions: + retryWrites: false + connectTimeoutMS: 250 + heartbeatFrequencyMS: 500 + appname: extendsTimeoutTest + - database: + id: &database database + client: *client + databaseName: *databaseName + - collection: + id: &collection collection + database: *database + collectionName: *collectionName + # Perform an operation to ensure the node is discovered. + - name: insertMany + object: *collection + arguments: + documents: + - _id: 1 + - _id: 2 + # Wait for multiple monitor checks to complete. + - name: wait + object: testRunner + arguments: + ms: 2000 + # Perform an operation to ensure the node is still selectable. + - name: insertMany + object: *collection + arguments: + documents: + - _id: 3 + - _id: 4 + # Assert that the server was never marked Unknown and the pool was never + # cleared. + - name: assertEventCount + object: testRunner + arguments: + client: *client + event: + serverDescriptionChangedEvent: + newDescription: + type: Unknown + count: 0 + - name: assertEventCount + object: testRunner + arguments: + client: *client + event: + poolClearedEvent: {} + count: 0 + expectEvents: + - client: *client + eventType: command + events: + - commandStartedEvent: + command: + insert: hello-timeout + documents: + - _id: 1 + - _id: 2 + commandName: insert + databaseName: *databaseName + - commandStartedEvent: + command: + insert: hello-timeout + documents: + - _id: 3 + - _id: 4 + commandName: insert + databaseName: *databaseName + outcome: + - collectionName: *collectionName + databaseName: *databaseName + documents: + - _id: 1 + - _id: 2 + - _id: 3 + - _id: 4 diff --git a/testdata/server-discovery-and-monitoring/unified/interruptInUse-pool-clear.json b/testdata/server-discovery-and-monitoring/unified/interruptInUse-pool-clear.json index be01143ca0..a20d79030a 100644 --- a/testdata/server-discovery-and-monitoring/unified/interruptInUse-pool-clear.json +++ b/testdata/server-discovery-and-monitoring/unified/interruptInUse-pool-clear.json @@ -588,4 +588,4 @@ ] } ] -} \ No newline at end of file +} diff --git a/testdata/server-discovery-and-monitoring/unified/interruptInUse-pool-clear.yml b/testdata/server-discovery-and-monitoring/unified/interruptInUse-pool-clear.yml index 5795bc72d6..1f241e8536 100644 --- a/testdata/server-discovery-and-monitoring/unified/interruptInUse-pool-clear.yml +++ b/testdata/server-discovery-and-monitoring/unified/interruptInUse-pool-clear.yml @@ -338,3 +338,4 @@ tests: databaseName: *databaseName documents: - { _id: 1, a : bar } + diff --git a/testdata/server-discovery-and-monitoring/unified/logging-loadbalanced.yml b/testdata/server-discovery-and-monitoring/unified/logging-loadbalanced.yml index 87ad4bcf5d..3f6058270f 100644 --- a/testdata/server-discovery-and-monitoring/unified/logging-loadbalanced.yml +++ b/testdata/server-discovery-and-monitoring/unified/logging-loadbalanced.yml @@ -71,4 +71,4 @@ tests: component: topology data: message: "Stopped topology monitoring" - topologyId: { $$exists: true } + topologyId: { $$exists: true } \ No newline at end of file diff --git a/testdata/server-discovery-and-monitoring/unified/logging-replicaset.json b/testdata/server-discovery-and-monitoring/unified/logging-replicaset.json index 8522c14e19..e6738225cd 100644 --- a/testdata/server-discovery-and-monitoring/unified/logging-replicaset.json +++ b/testdata/server-discovery-and-monitoring/unified/logging-replicaset.json @@ -220,6 +220,22 @@ } } }, + { + "level": "debug", + "component": "topology", + "data": { + "message": "Topology description changed", + "topologyId": { + "$$exists": true + }, + "previousDescription": { + "$$exists": true + }, + "newDescription": { + "$$exists": true + } + } + }, { "level": "debug", "component": "topology", diff --git a/testdata/server-discovery-and-monitoring/unified/logging-replicaset.yml b/testdata/server-discovery-and-monitoring/unified/logging-replicaset.yml index 176c4e5e18..a0b856ec72 100644 --- a/testdata/server-discovery-and-monitoring/unified/logging-replicaset.yml +++ b/testdata/server-discovery-and-monitoring/unified/logging-replicaset.yml @@ -109,13 +109,6 @@ tests: topologyId: { $$exists: true } serverHost: { $$type: string } serverPort: { $$type: [int, long] } - # TODO(GODRIVER-2967): The following log message has been removed from - # the JSON analogue because it assumes that - # "TopologyDescriptionChangedEvent" should occur when a topolgoy is - # closed. This behavior is not clearly defined anywhere and some - # drivers support and some don't. - # - # Need to sync whenever GODRIVER-2967 is unblocked. - level: debug component: topology data: @@ -293,4 +286,4 @@ tests: serverPort: { $$type: [int, long] } driverConnectionId: { $$exists: true } durationMS: { $$type: [int, long] } - failure: { $$exists: true } + failure: { $$exists: true } \ No newline at end of file diff --git a/testdata/server-discovery-and-monitoring/unified/logging-sharded.json b/testdata/server-discovery-and-monitoring/unified/logging-sharded.json index 33e7ec4bfe..61b27f5be0 100644 --- a/testdata/server-discovery-and-monitoring/unified/logging-sharded.json +++ b/testdata/server-discovery-and-monitoring/unified/logging-sharded.json @@ -187,6 +187,22 @@ } } }, + { + "level": "debug", + "component": "topology", + "data": { + "message": "Topology description changed", + "topologyId": { + "$$exists": true + }, + "previousDescription": { + "$$exists": true + }, + "newDescription": { + "$$exists": true + } + } + }, { "level": "debug", "component": "topology", diff --git a/testdata/server-discovery-and-monitoring/unified/logging-sharded.yml b/testdata/server-discovery-and-monitoring/unified/logging-sharded.yml index f175ce0f90..19870878b9 100644 --- a/testdata/server-discovery-and-monitoring/unified/logging-sharded.yml +++ b/testdata/server-discovery-and-monitoring/unified/logging-sharded.yml @@ -97,13 +97,6 @@ tests: topologyId: { $$exists: true } serverHost: { $$type: string } serverPort: { $$type: [int, long] } - # TODO(GODRIVER-2967): The following log message has been removed from - # the JSON analogue because it assumes that - # "TopologyDescriptionChangedEvent" should occur when a topolgoy is - # closed. This behavior is not clearly defined anywhere and some - # drivers support and some don't. - # - # Need to sync whenever GODRIVER-2967 is unblocked. - level: debug component: topology data: @@ -252,4 +245,4 @@ tests: serverPort: { $$type: [int, long] } driverConnectionId: { $$exists: true } durationMS: { $$type: [int, long] } - failure: { $$exists: true } + failure: { $$exists: true } \ No newline at end of file diff --git a/testdata/server-discovery-and-monitoring/unified/logging-standalone.json b/testdata/server-discovery-and-monitoring/unified/logging-standalone.json index f27d651afc..1ee6dbe899 100644 --- a/testdata/server-discovery-and-monitoring/unified/logging-standalone.json +++ b/testdata/server-discovery-and-monitoring/unified/logging-standalone.json @@ -162,6 +162,22 @@ } } }, + { + "level": "debug", + "component": "topology", + "data": { + "message": "Topology description changed", + "topologyId": { + "$$exists": true + }, + "previousDescription": { + "$$exists": true + }, + "newDescription": { + "$$exists": true + } + } + }, { "level": "debug", "component": "topology", diff --git a/testdata/server-discovery-and-monitoring/unified/logging-standalone.yml b/testdata/server-discovery-and-monitoring/unified/logging-standalone.yml index 0b378cd2fc..80cf98a20e 100644 --- a/testdata/server-discovery-and-monitoring/unified/logging-standalone.yml +++ b/testdata/server-discovery-and-monitoring/unified/logging-standalone.yml @@ -84,13 +84,6 @@ tests: topologyId: { $$exists: true } serverHost: { $$type: string } serverPort: { $$type: [int, long] } - # TODO(GODRIVER-2967): The following log message has been removed from - # the JSON analogue because it assumes that - # "TopologyDescriptionChangedEvent" should occur when a topolgoy is - # closed. This behavior is not clearly defined anywhere and some - # drivers support and some don't. - # - # Need to sync whenever GODRIVER-2967 is unblocked. - level: debug component: topology data: @@ -262,4 +255,4 @@ tests: serverPort: { $$type: [int, long] } driverConnectionId: { $$exists: true } durationMS: { $$type: [int, long] } - failure: { $$exists: true } + failure: { $$exists: true } \ No newline at end of file diff --git a/testdata/server-discovery-and-monitoring/unified/rediscover-quickly-after-step-down.json b/testdata/server-discovery-and-monitoring/unified/rediscover-quickly-after-step-down.json new file mode 100644 index 0000000000..3147a07a1e --- /dev/null +++ b/testdata/server-discovery-and-monitoring/unified/rediscover-quickly-after-step-down.json @@ -0,0 +1,242 @@ +{ + "description": "rediscover-quickly-after-step-down", + "schemaVersion": "1.4", + "runOnRequirements": [ + { + "minServerVersion": "4.4", + "serverless": "forbid", + "topologies": [ + "replicaset" + ] + } + ], + "createEntities": [ + { + "client": { + "id": "setupClient" + } + }, + { + "database": { + "id": "adminDatabase", + "client": "setupClient", + "databaseName": "admin" + } + } + ], + "initialData": [ + { + "collectionName": "test-replSetStepDown", + "databaseName": "sdam-tests", + "documents": [ + { + "_id": 1 + }, + { + "_id": 2 + } + ] + } + ], + "tests": [ + { + "description": "Rediscover quickly after replSetStepDown", + "operations": [ + { + "name": "createEntities", + "object": "testRunner", + "arguments": { + "entities": [ + { + "client": { + "id": "client", + "observeEvents": [ + "poolClearedEvent", + "commandStartedEvent" + ], + "uriOptions": { + "appname": "replSetStepDownTest", + "heartbeatFrequencyMS": 60000, + "serverSelectionTimeoutMS": 5000, + "w": "majority" + } + } + }, + { + "database": { + "id": "database", + "client": "client", + "databaseName": "sdam-tests" + } + }, + { + "collection": { + "id": "collection", + "database": "database", + "collectionName": "test-replSetStepDown" + } + } + ] + } + }, + { + "name": "insertMany", + "object": "collection", + "arguments": { + "documents": [ + { + "_id": 3 + }, + { + "_id": 4 + } + ] + } + }, + { + "name": "recordTopologyDescription", + "object": "testRunner", + "arguments": { + "client": "client", + "id": "topologyDescription" + } + }, + { + "name": "assertTopologyType", + "object": "testRunner", + "arguments": { + "topologyDescription": "topologyDescription", + "topologyType": "ReplicaSetWithPrimary" + } + }, + { + "name": "runCommand", + "object": "adminDatabase", + "arguments": { + "command": { + "replSetFreeze": 0 + }, + "readPreference": { + "mode": "secondary" + }, + "commandName": "replSetFreeze" + } + }, + { + "name": "runCommand", + "object": "adminDatabase", + "arguments": { + "command": { + "replSetStepDown": 30, + "secondaryCatchUpPeriodSecs": 30, + "force": false + }, + "commandName": "replSetStepDown" + } + }, + { + "name": "waitForPrimaryChange", + "object": "testRunner", + "arguments": { + "client": "client", + "priorTopologyDescription": "topologyDescription", + "timeoutMS": 15000 + } + }, + { + "name": "insertMany", + "object": "collection", + "arguments": { + "documents": [ + { + "_id": 5 + }, + { + "_id": 6 + } + ] + } + }, + { + "name": "assertEventCount", + "object": "testRunner", + "arguments": { + "client": "client", + "event": { + "poolClearedEvent": {} + }, + "count": 0 + } + } + ], + "expectEvents": [ + { + "client": "client", + "eventType": "command", + "events": [ + { + "commandStartedEvent": { + "command": { + "insert": "test-replSetStepDown", + "documents": [ + { + "_id": 3 + }, + { + "_id": 4 + } + ] + }, + "commandName": "insert", + "databaseName": "sdam-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "insert": "test-replSetStepDown", + "documents": [ + { + "_id": 5 + }, + { + "_id": 6 + } + ] + }, + "commandName": "insert", + "databaseName": "sdam-tests" + } + } + ] + } + ], + "outcome": [ + { + "collectionName": "test-replSetStepDown", + "databaseName": "sdam-tests", + "documents": [ + { + "_id": 1 + }, + { + "_id": 2 + }, + { + "_id": 3 + }, + { + "_id": 4 + }, + { + "_id": 5 + }, + { + "_id": 6 + } + ] + } + ] + } + ] +} diff --git a/testdata/server-discovery-and-monitoring/unified/rediscover-quickly-after-step-down.yml b/testdata/server-discovery-and-monitoring/unified/rediscover-quickly-after-step-down.yml new file mode 100644 index 0000000000..f3e7509160 --- /dev/null +++ b/testdata/server-discovery-and-monitoring/unified/rediscover-quickly-after-step-down.yml @@ -0,0 +1,144 @@ +--- +description: rediscover-quickly-after-step-down + +schemaVersion: "1.4" + +runOnRequirements: + # 4.4 is required for streaming. + # A replica set is required for replSetStepDown. + - minServerVersion: "4.4" + serverless: forbid + topologies: + - replicaset + +createEntities: + - client: + id: &setupClient setupClient + - database: + id: &adminDatabase adminDatabase + client: *setupClient + databaseName: admin + +initialData: &initialData + - collectionName: &collectionName test-replSetStepDown + databaseName: &databaseName sdam-tests + documents: + - _id: 1 + - _id: 2 + +tests: + - description: Rediscover quickly after replSetStepDown + operations: + - name: createEntities + object: testRunner + arguments: + entities: + - client: + id: &client client + observeEvents: + - poolClearedEvent + - commandStartedEvent + uriOptions: + appname: replSetStepDownTest + # Configure a large heartbeatFrequencyMS + heartbeatFrequencyMS: 60000 + # Configure a much smaller server selection timeout so that the test + # will error when it cannot discover the new primary soon. + serverSelectionTimeoutMS: 5000 + w: majority + - database: + id: &database database + client: *client + databaseName: *databaseName + - collection: + id: &collection collection + database: *database + collectionName: *collectionName + # Discover the primary. + - name: insertMany + object: *collection + arguments: + documents: + - _id: 3 + - _id: 4 + - name: recordTopologyDescription + object: testRunner + arguments: + client: *client + id: &topologyDescription topologyDescription + - name: assertTopologyType + object: testRunner + arguments: + topologyDescription: *topologyDescription + topologyType: ReplicaSetWithPrimary + # Unfreeze a secondary with replSetFreeze:0 to ensure a speedy election. + - name: runCommand + object: *adminDatabase + arguments: + command: + replSetFreeze: 0 + readPreference: + mode: secondary + commandName: replSetFreeze + # Run replSetStepDown on the meta client. + - name: runCommand + object: *adminDatabase + arguments: + command: + replSetStepDown: 30 + secondaryCatchUpPeriodSecs: 30 + force: false + commandName: replSetStepDown + - name: waitForPrimaryChange + object: testRunner + arguments: + client: *client + priorTopologyDescription: *topologyDescription + # We use a relatively large timeout here to workaround slow + # elections on Windows, possibly caused by SERVER-48154. + timeoutMS: 15000 + # Rediscover the new primary. + - name: insertMany + object: *collection + arguments: + documents: + - _id: 5 + - _id: 6 + # Assert that no pools were cleared. + - name: assertEventCount + object: testRunner + arguments: + client: *client + event: + poolClearedEvent: {} + count: 0 + expectEvents: + - client: *client + eventType: command + events: + - commandStartedEvent: + command: + insert: test-replSetStepDown + documents: + - _id: 3 + - _id: 4 + commandName: insert + databaseName: *databaseName + - commandStartedEvent: + command: + insert: test-replSetStepDown + documents: + - _id: 5 + - _id: 6 + commandName: insert + databaseName: *databaseName + outcome: + - collectionName: *collectionName + databaseName: *databaseName + documents: + - _id: 1 + - _id: 2 + - _id: 3 + - _id: 4 + - _id: 5 + - _id: 6 diff --git a/x/mongo/driver/operation/aggregate.go b/x/mongo/driver/operation/aggregate.go index 396a569389..a0cd5bd25e 100644 --- a/x/mongo/driver/operation/aggregate.go +++ b/x/mongo/driver/operation/aggregate.go @@ -198,7 +198,7 @@ func (a *Aggregate) BypassDocumentValidation(bypassDocumentValidation bool) *Agg return a } -// Collation specifies a collation. This option is only valid for server versions 3.4 and above. +// Collation specifies a collation. func (a *Aggregate) Collation(collation bsoncore.Document) *Aggregate { if a == nil { a = new(Aggregate) diff --git a/x/mongo/driver/operation/create.go b/x/mongo/driver/operation/create.go index 840d0ba469..f9a406dbc6 100644 --- a/x/mongo/driver/operation/create.go +++ b/x/mongo/driver/operation/create.go @@ -151,7 +151,7 @@ func (c *Create) Capped(capped bool) *Create { return c } -// Collation specifies a collation. This option is only valid for server versions 3.4 and above. +// Collation specifies a collation. func (c *Create) Collation(collation bsoncore.Document) *Create { if c == nil { c = new(Create) diff --git a/x/mongo/driver/operation/delete.go b/x/mongo/driver/operation/delete.go index 39420efc58..e6f47042a8 100644 --- a/x/mongo/driver/operation/delete.go +++ b/x/mongo/driver/operation/delete.go @@ -277,8 +277,7 @@ func (d *Delete) Retry(retry driver.RetryMode) *Delete { } // Hint is a flag to indicate that the update document contains a hint. Hint is only supported by -// servers >= 4.4. Older servers >= 3.4 will report an error for using the hint option. For servers < -// 3.4, the driver will return an error if the hint option is used. +// servers >= 4.4. Older servers will report an error for using the hint option. func (d *Delete) Hint(hint bool) *Delete { if d == nil { d = new(Delete) diff --git a/x/mongo/driver/operation/update.go b/x/mongo/driver/operation/update.go index 186f946313..722c06ef94 100644 --- a/x/mongo/driver/operation/update.go +++ b/x/mongo/driver/operation/update.go @@ -207,8 +207,7 @@ func (u *Update) command(dst []byte, desc description.SelectedServer) ([]byte, e return dst, nil } -// BypassDocumentValidation allows the operation to opt-out of document level validation. Valid -// for server versions >= 3.2. For servers < 3.2, this setting is ignored. +// BypassDocumentValidation allows the operation to opt-out of document level validation. func (u *Update) BypassDocumentValidation(bypassDocumentValidation bool) *Update { if u == nil { u = new(Update) @@ -219,8 +218,7 @@ func (u *Update) BypassDocumentValidation(bypassDocumentValidation bool) *Update } // Hint is a flag to indicate that the update document contains a hint. Hint is only supported by -// servers >= 4.2. Older servers >= 3.4 will report an error for using the hint option. For servers < -// 3.4, the driver will return an error if the hint option is used. +// servers >= 4.2. Older servers will report an error for using the hint option. func (u *Update) Hint(hint bool) *Update { if u == nil { u = new(Update) @@ -230,8 +228,7 @@ func (u *Update) Hint(hint bool) *Update { return u } -// ArrayFilters is a flag to indicate that the update document contains an arrayFilters field. This option is only -// supported on server versions 3.6 and higher. For servers < 3.6, the driver will return an error. +// ArrayFilters is a flag to indicate that the update document contains an arrayFilters field. func (u *Update) ArrayFilters(arrayFilters bool) *Update { if u == nil { u = new(Update) diff --git a/x/mongo/driver/topology/fsm.go b/x/mongo/driver/topology/fsm.go index 3cc06656fc..530b2169e6 100644 --- a/x/mongo/driver/topology/fsm.go +++ b/x/mongo/driver/topology/fsm.go @@ -20,7 +20,7 @@ import ( var ( // MinSupportedMongoDBVersion is the version string for the lowest MongoDB version supported by the driver. - MinSupportedMongoDBVersion = "3.6" + MinSupportedMongoDBVersion = "4.0" // SupportedWireVersions is the range of wire versions supported by the driver. SupportedWireVersions = driverutil.NewVersionRange(driverutil.MinWireVersion, driverutil.MaxWireVersion) diff --git a/x/mongo/driver/topology/topology_test.go b/x/mongo/driver/topology/topology_test.go index b4af40b920..205030f1e8 100644 --- a/x/mongo/driver/topology/topology_test.go +++ b/x/mongo/driver/topology/topology_test.go @@ -114,7 +114,7 @@ func TestServerSelection(t *testing.T) { } want := fmt.Errorf( "server at %s reports wire version %d, but this version of the Go driver requires "+ - "at least 6 (MongoDB 3.6)", + "at least 7 (MongoDB 4.0)", desc.Servers[0].Addr.String(), desc.Servers[0].WireVersion.Max, )