diff --git a/go.mod b/go.mod index 4baa6b1a..f100b18d 100644 --- a/go.mod +++ b/go.mod @@ -18,7 +18,7 @@ require ( github.com/swaggo/gin-swagger v1.6.0 github.com/swaggo/swag v1.16.4 github.com/umputun/go-flags v1.5.1 - go.mongodb.org/mongo-driver v1.17.2 + go.mongodb.org/mongo-driver v1.17.7 golang.org/x/net v0.47.0 golang.org/x/text v0.31.0 ) diff --git a/go.sum b/go.sum index a8bb55da..9673ce48 100644 --- a/go.sum +++ b/go.sum @@ -173,8 +173,8 @@ github.com/youmark/pkcs8 v0.0.0-20240726163527-a2c0da244d78/go.mod h1:aL8wCCfTfS github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= github.com/yusufpapurcu/wmi v1.2.4 h1:zFUKzehAFReQwLys1b/iSMl+JQGSCSjtVqQn9bBrPo0= github.com/yusufpapurcu/wmi v1.2.4/go.mod h1:SBZ9tNy3G9/m5Oi98Zks0QjeHVDvuK0qfxQmPyzfmi0= -go.mongodb.org/mongo-driver v1.17.2 h1:gvZyk8352qSfzyZ2UMWcpDpMSGEr1eqE4T793SqyhzM= -go.mongodb.org/mongo-driver v1.17.2/go.mod h1:Hy04i7O2kC4RS06ZrhPRqj/u4DTYkFDAAccj+rVKqgQ= +go.mongodb.org/mongo-driver v1.17.7 h1:a9w+U3Vt67eYzcfq3k/OAv284/uUUkL0uP75VE5rCOU= +go.mongodb.org/mongo-driver v1.17.7/go.mod h1:Hy04i7O2kC4RS06ZrhPRqj/u4DTYkFDAAccj+rVKqgQ= go.uber.org/atomic v1.11.0 h1:ZvwS0R+56ePWxUNi+Atn9dWONBPp/AUETXlHW0DxSjE= go.uber.org/atomic v1.11.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0= golang.org/x/arch v0.14.0 h1:z9JUEZWr8x4rR0OU6c4/4t6E6jOZ8/QBS2bBYBm4tx4= diff --git a/vendor/go.mongodb.org/mongo-driver/bson/bsoncodec/default_value_decoders.go b/vendor/go.mongodb.org/mongo-driver/bson/bsoncodec/default_value_decoders.go index 159297ef..8702d6d3 100644 --- a/vendor/go.mongodb.org/mongo-driver/bson/bsoncodec/default_value_decoders.go +++ b/vendor/go.mongodb.org/mongo-driver/bson/bsoncodec/default_value_decoders.go @@ -1521,7 +1521,13 @@ func (dvd DefaultValueDecoders) ValueUnmarshalerDecodeValue(_ DecodeContext, vr return ValueDecoderError{Name: "ValueUnmarshalerDecodeValue", Types: []reflect.Type{tValueUnmarshaler}, Received: val} } - if vr.Type() == bsontype.Null { + // If BSON value is null and the go value is a pointer, then don't call + // UnmarshalBSONValue. Even if the Go pointer is already initialized (i.e., + // non-nil), encountering null in BSON will result in the pointer being + // directly set to nil here. Since the pointer is being replaced with nil, + // there is no opportunity (or reason) for the custom UnmarshalBSONValue logic + // to be called. + if vr.Type() == bsontype.Null && val.Kind() == reflect.Ptr { val.Set(reflect.Zero(val.Type())) return vr.ReadNull() diff --git a/vendor/go.mongodb.org/mongo-driver/bson/bsonrw/extjson_writer.go b/vendor/go.mongodb.org/mongo-driver/bson/bsonrw/extjson_writer.go index 57781ff9..86a29357 100644 --- a/vendor/go.mongodb.org/mongo-driver/bson/bsonrw/extjson_writer.go +++ b/vendor/go.mongodb.org/mongo-driver/bson/bsonrw/extjson_writer.go @@ -468,12 +468,13 @@ func (ejvw *extJSONValueWriter) WriteRegex(pattern string, options string) error return err } + options = sortStringAlphebeticAscending(options) var buf bytes.Buffer buf.WriteString(`{"$regularExpression":{"pattern":`) writeStringWithEscapes(pattern, &buf, ejvw.escapeHTML) - buf.WriteString(`,"options":"`) - buf.WriteString(sortStringAlphebeticAscending(options)) - buf.WriteString(`"}},`) + buf.WriteString(`,"options":`) + writeStringWithEscapes(options, &buf, ejvw.escapeHTML) + buf.WriteString(`}},`) ejvw.buf = append(ejvw.buf, buf.Bytes()...) diff --git a/vendor/go.mongodb.org/mongo-driver/bson/unmarshal.go b/vendor/go.mongodb.org/mongo-driver/bson/unmarshal.go index 66da17ee..d749ba37 100644 --- a/vendor/go.mongodb.org/mongo-driver/bson/unmarshal.go +++ b/vendor/go.mongodb.org/mongo-driver/bson/unmarshal.go @@ -41,6 +41,9 @@ type ValueUnmarshaler interface { // Unmarshal parses the BSON-encoded data and stores the result in the value // pointed to by val. If val is nil or not a pointer, Unmarshal returns // InvalidUnmarshalError. +// +// When unmarshaling BSON, if the BSON value is null and the Go value is a +// pointer, the pointer is set to nil without calling UnmarshalBSONValue. func Unmarshal(data []byte, val interface{}) error { return UnmarshalWithRegistry(DefaultRegistry, data, val) } diff --git a/vendor/go.mongodb.org/mongo-driver/mongo/bulk_write.go b/vendor/go.mongodb.org/mongo-driver/mongo/bulk_write.go index 40f1181e..81dfbb1d 100644 --- a/vendor/go.mongodb.org/mongo-driver/mongo/bulk_write.go +++ b/vendor/go.mongodb.org/mongo-driver/mongo/bulk_write.go @@ -39,6 +39,7 @@ type bulkWrite struct { writeConcern *writeconcern.WriteConcern result BulkWriteResult let interface{} + bypassEmptyTsReplacement *bool } func (bw *bulkWrite) execute(ctx context.Context) error { @@ -207,6 +208,10 @@ func (bw *bulkWrite) runInsert(ctx context.Context, batch bulkWriteBatch) (opera } op = op.Retry(retry) + if bw.bypassEmptyTsReplacement != nil { + op.BypassEmptyTsReplacement(*bw.bypassEmptyTsReplacement) + } + err := op.Execute(ctx) return op.Result(), err @@ -415,6 +420,10 @@ func (bw *bulkWrite) runUpdate(ctx context.Context, batch bulkWriteBatch) (opera } op = op.Retry(retry) + if bw.bypassEmptyTsReplacement != nil { + op.BypassEmptyTsReplacement(*bw.bypassEmptyTsReplacement) + } + err := op.Execute(ctx) return op.Result(), err diff --git a/vendor/go.mongodb.org/mongo-driver/mongo/collection.go b/vendor/go.mongodb.org/mongo-driver/mongo/collection.go index dbe238a9..95889c80 100644 --- a/vendor/go.mongodb.org/mongo-driver/mongo/collection.go +++ b/vendor/go.mongodb.org/mongo-driver/mongo/collection.go @@ -234,6 +234,7 @@ func (coll *Collection) BulkWrite(ctx context.Context, models []WriteModel, selector: selector, writeConcern: wc, let: bwo.Let, + bypassEmptyTsReplacement: bwo.BypassEmptyTsReplacement, } err = op.execute(ctx) @@ -307,6 +308,9 @@ func (coll *Collection) insert(ctx context.Context, documents []interface{}, if imo.Ordered != nil { op = op.Ordered(*imo.Ordered) } + if imo.BypassEmptyTsReplacement != nil { + op = op.BypassEmptyTsReplacement(*imo.BypassEmptyTsReplacement) + } retry := driver.RetryNone if coll.client.retryWrites { retry = driver.RetryOncePerCommand @@ -355,6 +359,9 @@ func (coll *Collection) InsertOne(ctx context.Context, document interface{}, if ioOpts.Comment != nil { imOpts.SetComment(ioOpts.Comment) } + if ioOpts.BypassEmptyTsReplacement != nil { + imOpts.BypassEmptyTsReplacement = ioOpts.BypassEmptyTsReplacement + } res, err := coll.insert(ctx, []interface{}{document}, imOpts) rr, err := processWriteError(err) @@ -609,6 +616,9 @@ func (coll *Collection) updateOrReplace(ctx context.Context, filter bsoncore.Doc } op = op.Comment(comment) } + if uo.BypassEmptyTsReplacement != nil { + op.BypassEmptyTsReplacement(*uo.BypassEmptyTsReplacement) + } retry := driver.RetryNone // retryable writes are only enabled updateOne/replaceOne operations if !multi && coll.client.retryWrites { @@ -760,6 +770,7 @@ func (coll *Collection) ReplaceOne(ctx context.Context, filter interface{}, uOpts.Hint = opt.Hint uOpts.Let = opt.Let uOpts.Comment = opt.Comment + uOpts.BypassEmptyTsReplacement = opt.BypassEmptyTsReplacement updateOptions = append(updateOptions, uOpts) } @@ -1659,6 +1670,9 @@ func (coll *Collection) FindOneAndReplace(ctx context.Context, filter interface{ } op = op.Let(let) } + if fo.BypassEmptyTsReplacement != nil { + op = op.BypassEmptyTsReplacement(*fo.BypassEmptyTsReplacement) + } return coll.findAndModify(ctx, op) } @@ -1765,6 +1779,9 @@ func (coll *Collection) FindOneAndUpdate(ctx context.Context, filter interface{} } op = op.Let(let) } + if fo.BypassEmptyTsReplacement != nil { + op = op.BypassEmptyTsReplacement(*fo.BypassEmptyTsReplacement) + } return coll.findAndModify(ctx, op) } diff --git a/vendor/go.mongodb.org/mongo-driver/mongo/mongointernal.go b/vendor/go.mongodb.org/mongo-driver/mongo/mongointernal.go new file mode 100644 index 00000000..0148756f --- /dev/null +++ b/vendor/go.mongodb.org/mongo-driver/mongo/mongointernal.go @@ -0,0 +1,41 @@ +// Copyright (C) MongoDB, Inc. 2025-present. +// +// Licensed under the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. You may obtain +// a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 + +//go:build mongointernal + +package mongo + +import ( + "time" + + "go.mongodb.org/mongo-driver/bson" + "go.mongodb.org/mongo-driver/x/bsonx/bsoncore" + "go.mongodb.org/mongo-driver/x/mongo/driver/session" +) + +// NewSessionWithLSID returns a Session with the given sessionID document. The +// sessionID is a BSON document with key "id" containing a 16-byte UUID (binary +// subtype 4). +// +// Sessions returned by NewSessionWithLSID are never added to the driver's +// session pool. Calling "EndSession" or "ClientSession.SetServer" on a Session +// returned by NewSessionWithLSID will panic. +// +// NewSessionWithLSID is intended only for internal use and may be changed or +// removed at any time. +func NewSessionWithLSID(client *Client, sessionID bson.Raw) Session { + return &sessionImpl{ + clientSession: &session.Client{ + Server: &session.Server{ + SessionID: bsoncore.Document(sessionID), + LastUsed: time.Now(), + }, + ClientID: client.id, + }, + client: client, + deployment: client.deployment, + } +} diff --git a/vendor/go.mongodb.org/mongo-driver/mongo/options/bulkwriteoptions.go b/vendor/go.mongodb.org/mongo-driver/mongo/options/bulkwriteoptions.go index 153de0c7..49d7a0f5 100644 --- a/vendor/go.mongodb.org/mongo-driver/mongo/options/bulkwriteoptions.go +++ b/vendor/go.mongodb.org/mongo-driver/mongo/options/bulkwriteoptions.go @@ -29,6 +29,12 @@ type BulkWriteOptions struct { // parameter names to values. Values must be constant or closed expressions that do not reference document fields. // Parameters can then be accessed as variables in an aggregate expression context (e.g. "$$var"). Let interface{} + + // If true, the server accepts empty Timestamp as a literal rather than replacing it with the current time. + // + // Deprecated: This option is for internal use only and should not be set. It may be changed or removed in any + // release. + BypassEmptyTsReplacement *bool } // BulkWrite creates a new *BulkWriteOptions instance. @@ -88,6 +94,9 @@ func MergeBulkWriteOptions(opts ...*BulkWriteOptions) *BulkWriteOptions { if opt.Let != nil { b.Let = opt.Let } + if opt.BypassEmptyTsReplacement != nil { + b.BypassEmptyTsReplacement = opt.BypassEmptyTsReplacement + } } return b diff --git a/vendor/go.mongodb.org/mongo-driver/mongo/options/clientoptions.go b/vendor/go.mongodb.org/mongo-driver/mongo/options/clientoptions.go index c3a9d439..b1dc0b6a 100644 --- a/vendor/go.mongodb.org/mongo-driver/mongo/options/clientoptions.go +++ b/vendor/go.mongodb.org/mongo-driver/mongo/options/clientoptions.go @@ -1062,9 +1062,6 @@ func (c *ClientOptions) SetSRVServiceName(srvName string) *ClientOptions { // MergeClientOptions combines the given *ClientOptions into a single *ClientOptions in a last one wins fashion. // The specified options are merged with the existing options on the client, with the specified options taking // precedence. -// -// Deprecated: Merging options structs will not be supported in Go Driver 2.0. Users should create a -// single options struct instead. func MergeClientOptions(opts ...*ClientOptions) *ClientOptions { c := Client() diff --git a/vendor/go.mongodb.org/mongo-driver/mongo/options/findoptions.go b/vendor/go.mongodb.org/mongo-driver/mongo/options/findoptions.go index fa3bf119..5795f95a 100644 --- a/vendor/go.mongodb.org/mongo-driver/mongo/options/findoptions.go +++ b/vendor/go.mongodb.org/mongo-driver/mongo/options/findoptions.go @@ -675,6 +675,12 @@ type FindOneAndReplaceOptions struct { // Values must be constant or closed expressions that do not reference document fields. Parameters can then be // accessed as variables in an aggregate expression context (e.g. "$$var"). Let interface{} + + // If true, the server accepts empty Timestamp as a literal rather than replacing it with the current time. + // + // Deprecated: This option is for internal use only and should not be set. It may be changed or removed in any + // release. + BypassEmptyTsReplacement *bool } // FindOneAndReplace creates a new FindOneAndReplaceOptions instance. @@ -787,6 +793,9 @@ func MergeFindOneAndReplaceOptions(opts ...*FindOneAndReplaceOptions) *FindOneAn if opt.Let != nil { fo.Let = opt.Let } + if opt.BypassEmptyTsReplacement != nil { + fo.BypassEmptyTsReplacement = opt.BypassEmptyTsReplacement + } } return fo @@ -852,6 +861,12 @@ type FindOneAndUpdateOptions struct { // Values must be constant or closed expressions that do not reference document fields. Parameters can then be // accessed as variables in an aggregate expression context (e.g. "$$var"). Let interface{} + + // If true, the server accepts empty Timestamp as a literal rather than replacing it with the current time. + // + // Deprecated: This option is for internal use only and should not be set. It may be changed or removed in any + // release. + BypassEmptyTsReplacement *bool } // FindOneAndUpdate creates a new FindOneAndUpdateOptions instance. @@ -973,6 +988,9 @@ func MergeFindOneAndUpdateOptions(opts ...*FindOneAndUpdateOptions) *FindOneAndU if opt.Let != nil { fo.Let = opt.Let } + if opt.BypassEmptyTsReplacement != nil { + fo.BypassEmptyTsReplacement = opt.BypassEmptyTsReplacement + } } return fo diff --git a/vendor/go.mongodb.org/mongo-driver/mongo/options/insertoptions.go b/vendor/go.mongodb.org/mongo-driver/mongo/options/insertoptions.go index 82137c60..f84f799d 100644 --- a/vendor/go.mongodb.org/mongo-driver/mongo/options/insertoptions.go +++ b/vendor/go.mongodb.org/mongo-driver/mongo/options/insertoptions.go @@ -17,6 +17,12 @@ type InsertOneOptions struct { // A string or document that will be included in server logs, profiling logs, and currentOp queries to help trace // the operation. The default value is nil, which means that no comment will be included in the logs. Comment interface{} + + // If true, the server accepts empty Timestamp as a literal rather than replacing it with the current time. + // + // Deprecated: This option is for internal use only and should not be set. It may be changed or removed in any + // release. + BypassEmptyTsReplacement *bool } // InsertOne creates a new InsertOneOptions instance. @@ -53,6 +59,9 @@ func MergeInsertOneOptions(opts ...*InsertOneOptions) *InsertOneOptions { if ioo.Comment != nil { ioOpts.Comment = ioo.Comment } + if ioo.BypassEmptyTsReplacement != nil { + ioOpts.BypassEmptyTsReplacement = ioo.BypassEmptyTsReplacement + } } return ioOpts @@ -72,6 +81,12 @@ type InsertManyOptions struct { // If true, no writes will be executed after one fails. The default value is true. Ordered *bool + + // If true, the server accepts empty Timestamp as a literal rather than replacing it with the current time. + // + // Deprecated: This option is for internal use only and should not be set. It may be changed or removed in any + // release. + BypassEmptyTsReplacement *bool } // InsertMany creates a new InsertManyOptions instance. @@ -119,6 +134,9 @@ func MergeInsertManyOptions(opts ...*InsertManyOptions) *InsertManyOptions { if imo.Ordered != nil { imOpts.Ordered = imo.Ordered } + if imo.BypassEmptyTsReplacement != nil { + imOpts.BypassEmptyTsReplacement = imo.BypassEmptyTsReplacement + } } return imOpts diff --git a/vendor/go.mongodb.org/mongo-driver/mongo/options/replaceoptions.go b/vendor/go.mongodb.org/mongo-driver/mongo/options/replaceoptions.go index f7d39601..ae3e7849 100644 --- a/vendor/go.mongodb.org/mongo-driver/mongo/options/replaceoptions.go +++ b/vendor/go.mongodb.org/mongo-driver/mongo/options/replaceoptions.go @@ -40,6 +40,12 @@ type ReplaceOptions struct { // Values must be constant or closed expressions that do not reference document fields. Parameters can then be // accessed as variables in an aggregate expression context (e.g. "$$var"). Let interface{} + + // If true, the server accepts empty Timestamp as a literal rather than replacing it with the current time. + // + // Deprecated: This option is for internal use only and should not be set. It may be changed or removed in any + // release. + BypassEmptyTsReplacement *bool } // Replace creates a new ReplaceOptions instance. @@ -112,6 +118,9 @@ func MergeReplaceOptions(opts ...*ReplaceOptions) *ReplaceOptions { if ro.Let != nil { rOpts.Let = ro.Let } + if ro.BypassEmptyTsReplacement != nil { + rOpts.BypassEmptyTsReplacement = ro.BypassEmptyTsReplacement + } } return rOpts diff --git a/vendor/go.mongodb.org/mongo-driver/mongo/options/updateoptions.go b/vendor/go.mongodb.org/mongo-driver/mongo/options/updateoptions.go index 5206f9f0..9f22ca90 100644 --- a/vendor/go.mongodb.org/mongo-driver/mongo/options/updateoptions.go +++ b/vendor/go.mongodb.org/mongo-driver/mongo/options/updateoptions.go @@ -45,6 +45,12 @@ type UpdateOptions struct { // Values must be constant or closed expressions that do not reference document fields. Parameters can then be // accessed as variables in an aggregate expression context (e.g. "$$var"). Let interface{} + + // If true, the server accepts empty Timestamp as a literal rather than replacing it with the current time. + // + // Deprecated: This option is for internal use only and should not be set. It may be changed or removed in any + // release. + BypassEmptyTsReplacement *bool } // Update creates a new UpdateOptions instance. @@ -125,6 +131,9 @@ func MergeUpdateOptions(opts ...*UpdateOptions) *UpdateOptions { if uo.Let != nil { uOpts.Let = uo.Let } + if uo.BypassEmptyTsReplacement != nil { + uOpts.BypassEmptyTsReplacement = uo.BypassEmptyTsReplacement + } } return uOpts diff --git a/vendor/go.mongodb.org/mongo-driver/version/version.go b/vendor/go.mongodb.org/mongo-driver/version/version.go index 37c900c2..5a84cd52 100644 --- a/vendor/go.mongodb.org/mongo-driver/version/version.go +++ b/vendor/go.mongodb.org/mongo-driver/version/version.go @@ -4,8 +4,11 @@ // not use this file except in compliance with the License. You may obtain // a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 +// DO NOT EDIT. Code generated by Github action +// "mongodb-labs/drivers-github-tools/golang/pre-publish". + // Package version defines the Go Driver version. -package version // import "go.mongodb.org/mongo-driver/version" +package version // Driver is the current version of the driver. -var Driver = "1.17.2" +var Driver = "1.17.7" diff --git a/vendor/go.mongodb.org/mongo-driver/x/mongo/driver/auth/internal/gssapi/gss_wrapper.c b/vendor/go.mongodb.org/mongo-driver/x/mongo/driver/auth/internal/gssapi/gss_wrapper.c index 68b72541..e426037e 100644 --- a/vendor/go.mongodb.org/mongo-driver/x/mongo/driver/auth/internal/gssapi/gss_wrapper.c +++ b/vendor/go.mongodb.org/mongo-driver/x/mongo/driver/auth/internal/gssapi/gss_wrapper.c @@ -72,8 +72,8 @@ int gssapi_error_desc( free(*desc); } - *desc = malloc(desc_buffer.length+1); - memcpy(*desc, desc_buffer.value, desc_buffer.length+1); + *desc = calloc(1, desc_buffer.length + 1); + memcpy(*desc, desc_buffer.value, desc_buffer.length); gss_release_buffer(&local_min_stat, &desc_buffer); } @@ -144,8 +144,8 @@ int gssapi_client_username( return GSSAPI_ERROR; } - *username = malloc(name_buffer.length+1); - memcpy(*username, name_buffer.value, name_buffer.length+1); + *username = calloc(1, name_buffer.length + 1); + memcpy(*username, name_buffer.value, name_buffer.length); gss_release_buffer(&ignored, &name_buffer); gss_release_name(&ignored, &name); diff --git a/vendor/go.mongodb.org/mongo-driver/x/mongo/driver/operation/find_and_modify.go b/vendor/go.mongodb.org/mongo-driver/x/mongo/driver/operation/find_and_modify.go index ea365ccb..89f88747 100644 --- a/vendor/go.mongodb.org/mongo-driver/x/mongo/driver/operation/find_and_modify.go +++ b/vendor/go.mongodb.org/mongo-driver/x/mongo/driver/operation/find_and_modify.go @@ -52,6 +52,7 @@ type FindAndModify struct { serverAPI *driver.ServerAPIOptions let bsoncore.Document timeout *time.Duration + bypassEmptyTsReplacement *bool result FindAndModifyResult } @@ -214,6 +215,9 @@ func (fam *FindAndModify) command(dst []byte, desc description.SelectedServer) ( if fam.let != nil { dst = bsoncore.AppendDocumentElement(dst, "let", fam.let) } + if fam.bypassEmptyTsReplacement != nil { + dst = bsoncore.AppendBooleanElement(dst, "bypassEmptyTsReplacement", *fam.bypassEmptyTsReplacement) + } return dst, nil } @@ -489,3 +493,13 @@ func (fam *FindAndModify) Authenticator(authenticator driver.Authenticator) *Fin fam.authenticator = authenticator return fam } + +// BypassEmptyTsReplacement sets the bypassEmptyTsReplacement to use for this operation. +func (fam *FindAndModify) BypassEmptyTsReplacement(bypassEmptyTsReplacement bool) *FindAndModify { + if fam == nil { + fam = new(FindAndModify) + } + + fam.bypassEmptyTsReplacement = &bypassEmptyTsReplacement + return fam +} diff --git a/vendor/go.mongodb.org/mongo-driver/x/mongo/driver/operation/insert.go b/vendor/go.mongodb.org/mongo-driver/x/mongo/driver/operation/insert.go index a65a4895..eea285b4 100644 --- a/vendor/go.mongodb.org/mongo-driver/x/mongo/driver/operation/insert.go +++ b/vendor/go.mongodb.org/mongo-driver/x/mongo/driver/operation/insert.go @@ -43,6 +43,7 @@ type Insert struct { result InsertResult serverAPI *driver.ServerAPIOptions timeout *time.Duration + bypassEmptyTsReplacement *bool logger *logger.Logger } @@ -131,6 +132,9 @@ func (i *Insert) command(dst []byte, desc description.SelectedServer) ([]byte, e if i.ordered != nil { dst = bsoncore.AppendBooleanElement(dst, "ordered", *i.ordered) } + if i.bypassEmptyTsReplacement != nil { + dst = bsoncore.AppendBooleanElement(dst, "bypassEmptyTsReplacement", *i.bypassEmptyTsReplacement) + } return dst, nil } @@ -317,3 +321,13 @@ func (i *Insert) Authenticator(authenticator driver.Authenticator) *Insert { i.authenticator = authenticator return i } + +// BypassEmptyTsReplacement sets the bypassEmptyTsReplacement to use for this operation. +func (i *Insert) BypassEmptyTsReplacement(bypassEmptyTsReplacement bool) *Insert { + if i == nil { + i = new(Insert) + } + + i.bypassEmptyTsReplacement = &bypassEmptyTsReplacement + return i +} diff --git a/vendor/go.mongodb.org/mongo-driver/x/mongo/driver/operation/update.go b/vendor/go.mongodb.org/mongo-driver/x/mongo/driver/operation/update.go index 1070e7ca..a33c67ee 100644 --- a/vendor/go.mongodb.org/mongo-driver/x/mongo/driver/operation/update.go +++ b/vendor/go.mongodb.org/mongo-driver/x/mongo/driver/operation/update.go @@ -47,6 +47,7 @@ type Update struct { serverAPI *driver.ServerAPIOptions let bsoncore.Document timeout *time.Duration + bypassEmptyTsReplacement *bool logger *logger.Logger } @@ -204,6 +205,9 @@ func (u *Update) command(dst []byte, desc description.SelectedServer) ([]byte, e if u.let != nil { dst = bsoncore.AppendDocumentElement(dst, "let", u.let) } + if u.bypassEmptyTsReplacement != nil { + dst = bsoncore.AppendBooleanElement(dst, "bypassEmptyTsReplacement", *u.bypassEmptyTsReplacement) + } return dst, nil } @@ -426,3 +430,13 @@ func (u *Update) Authenticator(authenticator driver.Authenticator) *Update { u.authenticator = authenticator return u } + +// BypassEmptyTsReplacement sets the bypassEmptyTsReplacement to use for this operation. +func (u *Update) BypassEmptyTsReplacement(bypassEmptyTsReplacement bool) *Update { + if u == nil { + u = new(Update) + } + + u.bypassEmptyTsReplacement = &bypassEmptyTsReplacement + return u +} diff --git a/vendor/go.mongodb.org/mongo-driver/x/mongo/driver/topology/connection.go b/vendor/go.mongodb.org/mongo-driver/x/mongo/driver/topology/connection.go index e00363a5..bad00e74 100644 --- a/vendor/go.mongodb.org/mongo-driver/x/mongo/driver/topology/connection.go +++ b/vendor/go.mongodb.org/mongo-driver/x/mongo/driver/topology/connection.go @@ -14,7 +14,6 @@ import ( "fmt" "io" "net" - "os" "strings" "sync" "sync/atomic" @@ -567,48 +566,6 @@ func (c *connection) closed() bool { return atomic.LoadInt64(&c.state) == connDisconnected } -// isAlive returns true if the connection is alive and ready to be used for an -// operation. -// -// Note that the liveness check can be slow (at least 1ms), so isAlive only -// checks the liveness of the connection if it's been idle for at least 10 -// seconds. For frequently in-use connections, a network error during an -// operation will be the first indication of a dead connection. -func (c *connection) isAlive() bool { - if c.nc == nil { - return false - } - - // If the connection has been idle for less than 10 seconds, skip the - // liveness check. - // - // The 10-seconds idle bypass is based on the liveness check implementation - // in the Python Driver. That implementation uses 1 second as the idle - // threshold, but we chose to be more conservative in the Go Driver because - // this is new behavior with unknown side-effects. See - // https://github.com/mongodb/mongo-python-driver/blob/e6b95f65953e01e435004af069a6976473eaf841/pymongo/synchronous/pool.py#L983-L985 - idleStart, ok := c.idleStart.Load().(time.Time) - if !ok || idleStart.Add(10*time.Second).After(time.Now()) { - return true - } - - // Set a 1ms read deadline and attempt to read 1 byte from the connection. - // Expect it to block for 1ms then return a deadline exceeded error. If it - // returns any other error, the connection is not usable, so return false. - // If it doesn't return an error and actually reads data, the connection is - // also not usable, so return false. - // - // Note that we don't need to un-set the read deadline because the "read" - // and "write" methods always reset the deadlines. - err := c.nc.SetReadDeadline(time.Now().Add(1 * time.Millisecond)) - if err != nil { - return false - } - var b [1]byte - _, err = c.nc.Read(b[:]) - return errors.Is(err, os.ErrDeadlineExceeded) -} - func (c *connection) idleTimeoutExpired() bool { if c.idleTimeout == 0 { return false diff --git a/vendor/go.mongodb.org/mongo-driver/x/mongo/driver/topology/pool.go b/vendor/go.mongodb.org/mongo-driver/x/mongo/driver/topology/pool.go index e9565425..45b0b7d9 100644 --- a/vendor/go.mongodb.org/mongo-driver/x/mongo/driver/topology/pool.go +++ b/vendor/go.mongodb.org/mongo-driver/x/mongo/driver/topology/pool.go @@ -167,11 +167,9 @@ type reason struct { // connectionPerished checks if a given connection is perished and should be removed from the pool. func connectionPerished(conn *connection) (reason, bool) { switch { - case conn.closed() || !conn.isAlive(): + case conn.closed(): // A connection would only be closed if it encountered a network error - // during an operation and closed itself. If a connection is not alive - // (e.g. the connection was closed by the server-side), it's also - // considered a network error. + // during an operation and closed itself. return reason{ loggerConn: logger.ReasonConnClosedError, event: event.ReasonError, diff --git a/vendor/modules.txt b/vendor/modules.txt index eaf2b89b..970e4740 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -290,7 +290,7 @@ github.com/youmark/pkcs8 # github.com/yusufpapurcu/wmi v1.2.4 ## explicit; go 1.16 github.com/yusufpapurcu/wmi -# go.mongodb.org/mongo-driver v1.17.2 +# go.mongodb.org/mongo-driver v1.17.7 ## explicit; go 1.18 go.mongodb.org/mongo-driver/bson go.mongodb.org/mongo-driver/bson/bsoncodec