Detailed steps to reproduce the problem?
Concerning tailable awaitData cursors:
Drivers MUST error if this option is set, timeoutMS is set to a non-zero value, and maxAwaitTimeMS is greater than or equal to timeoutMS.
There are three collection helpers that can create a tailable awaitData cursor: Collection.Find(), Collection.Aggregate(), and Collection.Watch(). Only Collection.Watch() implements this validation, but does so at the Next() level instead of at cursor construction.
The following can be used to reproduce the problem:
package main import ( "context" "fmt" "log" "time" "go.mongodb.org/mongo-driver/v2/bson" "go.mongodb.org/mongo-driver/v2/mongo" "go.mongodb.org/mongo-driver/v2/mongo/options" ) func main() { client, err := mongo.Connect(options.Client()) if err != nil { log.Fatal("failed to connect to server: %v", err) } defer func() { if err = client.Disconnect(context.Background()); err != nil { log.Fatal("failed to disconnect client: %v", err) } }() // Specify the database and collection db := client.Database("exampleDB") coll := db.Collection("exampleCappedCollection") opts := options.Find().SetMaxAwaitTime(10 * time.Second) ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second) defer cancel() _, err = coll.Find(ctx, bson.D{}, opts) fmt.Printf("expect validation error, got: %v\n", err != nil) }
Output:
expect validation error: false
Definition of done: what must be done to consider the task complete?
- Add the above validation to Collection.Find(), Collection.Aggregate(), and Collection.Watch(). See the Java implementation concerning change streams here.
- Remove the iterative validation from Collection.Watch()
The exact Go version used, with patch level:
go version go1.23.1 darwin/arm64
The exact version of the Go driver used:
2.0.0
Describe how MongoDB is set up. Local vs Hosted, version, topology, load balanced, etc.
NA
The operating system and version (e.g. Windows 7, OSX 10.8, ...)
NA
Security Vulnerabilities
NA
- has to be done before
-
GODRIVER-3173 CSOT avoid connection churn when operations timeout
- Backlog
- related to
-
DRIVERS-3092 Ensure Driver Errors for Tailable AwaitData Cursors on Invalid maxAwaitTimeMS
- Needs Triage