[GODRIVER-987] Pool exhausts with MongoDB v3.0.4 Created: 20/Apr/19  Updated: 15/Jan/20  Resolved: 15/Jan/20

Status: Closed
Project: Go Driver
Component/s: Core API
Affects Version/s: 1.0.1
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: moptym Assignee: Kristofer Brandow (Inactive)
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

CentOS 7 & Go 1.11.4 & MongoDB 3.0.4 (mmapv1)


Issue Links:
Problem/Incident
is caused by GODRIVER-1096 When limit is set with a BatchCursor ... Closed

 Description   

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



 Comments   
Comment by Divjot Arora (Inactive) [ 15/Jan/20 ]

Closing as the work for this ticket was done in GODRIVER-1096.

Comment by Kristofer Brandow (Inactive) [ 29/May/19 ]

Hi moptym,

I've found the issue and opened GODRIVER-1096 to resolve it. We are leaking a connection when we attempt to get more results from the server.

Comment by moptym [ 23/Apr/19 ]

It can't be reproduced with small collection.

const bulk = db.test.initializeUnorderedBulkOp()
for (let i = 0; i < 10000; i++) {
	bulk.insert({
		answer: 42
	})
}
bulk.execute()

Comment by Kristofer Brandow (Inactive) [ 22/Apr/19 ]

Hi moptym, I can't reproduce this. Can you include inserting data into a clean collection to show this bug? For reference, below is the output after letting this run for a couple seconds:

2019/04/22 12:09:17 3731 132.553µs
2019/04/22 12:09:17 3732 204.924µs
2019/04/22 12:09:17 3733 206.731µs
2019/04/22 12:09:17 3734 209.909µs
2019/04/22 12:09:17 3735 181.015µs
2019/04/22 12:09:17 3736 195.345µs
2019/04/22 12:09:17 3737 168.267µs
2019/04/22 12:09:17 3738 155.059µs
2019/04/22 12:09:17 3739 179.783µs
2019/04/22 12:09:17 3740 260.17µs
2019/04/22 12:09:17 3741 147.111µs
2019/04/22 12:09:17 3742 218.863µs
2019/04/22 12:09:17 3743 182.188µs
2019/04/22 12:09:17 3744 160.404µs
2019/04/22 12:09:17 3745 169.924µs
2019/04/22 12:09:17 3746 159.565µs
2019/04/22 12:09:17 3747 158.247µs
2019/04/22 12:09:17 3748 157.757µs
2019/04/22 12:09:17 3749 166.305µs
2019/04/22 12:09:17 3750 150.124µs
2019/04/22 12:09:17 3751 195.795µs
2019/04/22 12:09:17 3752 160.923µs
2019/04/22 12:09:17 3753 222.998µs
2019/04/22 12:09:17 3754 216.914µs
2019/04/22 12:09:17 3755 182.626µs
2019/04/22 12:09:17 3756 147.678µs
2019/04/22 12:09:17 3757 260.308µs
2019/04/22 12:09:17 3758 263.584µs
2019/04/22 12:09:17 3759 171.787µs
2019/04/22 12:09:17 3760 200.522µs
2019/04/22 12:09:17 3761 222.647µs
2019/04/22 12:09:17 3762 186.909µs
2019/04/22 12:09:17 3763 174.062µs
2019/04/22 12:09:17 3764 221.402µs
2019/04/22 12:09:17 3765 163.545µs
2019/04/22 12:09:17 3766 237.256µs
2019/04/22 12:09:17 3767 222.068µs
2019/04/22 12:09:17 3768 338.576µs
2019/04/22 12:09:17 3769 158.18µs
2019/04/22 12:09:17 3770 195.879µs
2019/04/22 12:09:17 3771 253.743µs
2019/04/22 12:09:17 3772 138.816µs
2019/04/22 12:09:17 3773 239.344µs
2019/04/22 12:09:17 3774 218.98µs
2019/04/22 12:09:17 3775 216.448µs
2019/04/22 12:09:17 3776 201.776µs
2019/04/22 12:09:17 3777 188.429µs
2019/04/22 12:09:17 3778 190.206µs
2019/04/22 12:09:17 3779 194.016µs
2019/04/22 12:09:17 3780 176.864µs
2019/04/22 12:09:17 3781 167.823µs
2019/04/22 12:09:17 3782 349.014µs
2019/04/22 12:09:17 3783 349.34µs
2019/04/22 12:09:17 3784 233.02µs
2019/04/22 12:09:17 3785 257.379µs
2019/04/22 12:09:17 3786 371.051µs
2019/04/22 12:09:17 3787 185.203µs
2019/04/22 12:09:17 3788 214.805µs
2019/04/22 12:09:17 3789 167.494µs
2019/04/22 12:09:17 3790 211.192µs
2019/04/22 12:09:17 3791 191.375µs 

 

--Kris

Generated at Thu Feb 08 08:35:24 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.