-
Type: Bug
-
Resolution: Done
-
Priority: Major - P3
-
None
-
Affects Version/s: 1.0.1
-
Component/s: Core API
-
None
-
Environment:CentOS 7 & Go 1.11.4 & MongoDB 3.0.4 (mmapv1)
Pool exhausts after executing some query using limit and Cursor.Next() on MongoDB v3.0.4, version 1.0.0 dosen't have this problem.
package main import ( "context" "go.mongodb.org/mongo-driver/bson" "go.mongodb.org/mongo-driver/mongo" "go.mongodb.org/mongo-driver/mongo/options" "log" "time" ) func main() { opt := options.Client().ApplyURI("mongodb://xxx") opt.SetMaxPoolSize(10) // important client, err := mongo.NewClient(opt) ctx, _ := context.WithTimeout(context.Background(), 10*time.Second) if err = client.Connect(ctx); err != nil { log.Fatal(err) } for i := 0; true; i++ { startTime := time.Now() col := client.Database("xxx").Collection("xxx") filter := bson.M{} opt := options.FindOptions{} opt.SetLimit(1) // important ctx, _ = context.WithTimeout(context.Background(), 5*time.Second) cur, err := col.Find(ctx, filter, &opt) if err != nil { log.Fatal(err) } defer cur.Close(ctx) for cur.Next(ctx) { // important } log.Println(i, time.Since(startTime)) } } // output: // // 2019/04/20 12:05:30 0 1.255561118s // 2019/04/20 12:05:30 1 656.780938ms // 2019/04/20 12:05:31 2 877.063852ms // 2019/04/20 12:05:32 3 1.024375444s // 2019/04/20 12:05:33 4 887.392948ms // 2019/04/20 12:05:34 5 946.072635ms // 2019/04/20 12:05:35 6 1.049663158s // 2019/04/20 12:05:36 7 802.969367ms // 2019/04/20 12:05:37 8 1.039775024s // 2019/04/20 12:05:42 9 5.000851648s // 2019/04/20 12:05:47 context deadline exceeded
- is caused by
-
GODRIVER-1096 When limit is set with a BatchCursor connected to a legacy server, a connection is leaked
- Closed