[SERVER-55581] return connection back to the pool in getUnshardedCollInfo Created: 28/Mar/21  Updated: 12/May/22  Resolved: 16/Aug/21

Status: Closed
Project: Core Server
Component/s: Networking
Affects Version/s: 4.0.20
Fix Version/s: 4.2.15, 4.4.7, 5.0.2, 4.0.27

Type: Bug Priority: Major - P3
Reporter: peng zhenyi Assignee: Tyler Seip (Inactive)
Resolution: Duplicate Votes: 0
Labels: pull-request, servicearch-wfbf-day
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Backports
Duplicate
duplicates SERVER-59400 Fix the regression introduced by SERV... Closed
Problem/Incident
Related
is related to SERVER-59388 Revert BACKPORT-10185 Closed
Operating System: ALL
Backport Requested:
v5.0, v4.4, v4.2, v4.0
Sprint: Service Arch 2021-08-09
Participants:
Linked BF Score: 84
Story Points: 2

 Description   

In "getUnshardedCollInfo", the newly created ScopedDbConnection is not returned to the globalConnPool.
This may lead to "connection leak".

Acceptance criteria: Confirm whether this a bug and if so, make sure the connection doesn't leak. 



 Comments   
Comment by Githook User [ 12/May/22 ]

Author:

{'name': 'Amirsaman Memaripour', 'email': 'amirsaman.memaripour@mongodb.com', 'username': 'samanca'}

Message: SERVER-59400 Revert "SERVER-55581: Return ScopedDbConnection to connection pool in cluster aggregation planner"

This reverts commit 663e90bbe862969572246b7b442845ed83a2472d.

(cherry picked from commit 81fa710687e399d7aa2bd093987396c6f6a36956)
Branch: v6.0
https://github.com/mongodb/mongo/commit/e1d4cd0bffd26fbbd3d0c0f58eea0ff4b4982238

Comment by Githook User [ 11/May/22 ]

Author:

{'name': 'Amirsaman Memaripour', 'email': 'amirsaman.memaripour@mongodb.com', 'username': 'samanca'}

Message: SERVER-59400 Revert "SERVER-55581: Return ScopedDbConnection to connection pool in cluster aggregation planner"

This reverts commit 663e90bbe862969572246b7b442845ed83a2472d.
Branch: master
https://github.com/mongodb/mongo/commit/81fa710687e399d7aa2bd093987396c6f6a36956

Comment by Tyler Seip (Inactive) [ 16/Aug/21 ]

Marking this ticket as a duplicate of SERVER-59400, which tracks the outstanding work of this ticket.

Comment by Tyler Seip (Inactive) [ 16/Aug/21 ]

The 4.2 revert is being tracked by SERVER-59388.

Comment by Githook User [ 12/Aug/21 ]

Author:

{'name': 'Tyler Seip', 'email': 'Tyler.Seip@mongodb.com', 'username': 'tseip-mongo'}

Message: Revert "SERVER-55581: Return ScopedDbConnection to connection pool in cluster aggregate"

This reverts commit e830129078cb6c6d7c90b50ce62ab7f6669b12ec.
Branch: v4.2
https://github.com/mongodb/mongo/commit/7bb37623c2ec55ea6aa66c9653b7be3003547eb7

Comment by Githook User [ 12/Aug/21 ]

Author:

{'name': 'Tyler Seip', 'email': 'Tyler.Seip@mongodb.com', 'username': 'tseip-mongo'}

Message: Revert "SERVER-55581: Return ScopedDbConnection to connection pool in cluster aggregate"

This reverts commit b4e064826b951bd9890c0cf62ae3ccc8a73917c0.
Branch: v4.0
https://github.com/mongodb/mongo/commit/5f4859e07684580c4ecafdb8ea1682d2bb856ee9

Comment by Githook User [ 09/Aug/21 ]

Author:

{'name': 'Tyler Seip', 'email': 'Tyler.Seip@mongodb.com', 'username': 'tseip-mongo'}

Message: SERVER-55581: Return ScopedDbConnection to connection pool in cluster aggregate
Branch: v4.2
https://github.com/mongodb/mongo/commit/e830129078cb6c6d7c90b50ce62ab7f6669b12ec

Comment by Githook User [ 09/Aug/21 ]

Author:

{'name': 'Tyler Seip', 'email': 'Tyler.Seip@mongodb.com', 'username': 'tseip-mongo'}

Message: SERVER-55581: Return ScopedDbConnection to connection pool in cluster aggregate
Branch: v4.0
https://github.com/mongodb/mongo/commit/b4e064826b951bd9890c0cf62ae3ccc8a73917c0

Comment by Githook User [ 09/Aug/21 ]

Author:

{'name': 'Tyler Seip', 'email': 'Tyler.Seip@mongodb.com', 'username': 'tseip-mongo'}

Message: SERVER-55581: Return ScopedDbConnection to connection pool in cluster aggregation planner

(cherry picked from commit 663e90bbe862969572246b7b442845ed83a2472d)
Branch: v5.0
https://github.com/mongodb/mongo/commit/7f690b6890e9f6a9391b2e7dbc5767b325f0c204

Comment by Githook User [ 09/Aug/21 ]

Author:

{'name': 'Tyler Seip', 'email': 'Tyler.Seip@mongodb.com', 'username': 'tseip-mongo'}

Message: SERVER-55581: Return ScopedDbConnection to connection pool in cluster aggregation planner

(cherry picked from commit 663e90bbe862969572246b7b442845ed83a2472d)
Branch: v4.4
https://github.com/mongodb/mongo/commit/53d9c0f1ad2e3b7d6befb0135395e782b233fed0

Comment by Tyler Seip (Inactive) [ 09/Aug/21 ]

Yes, I'll be backporting this change this week; you can watch BACKPORT-10186 for more details. I'll try and get to it today!

Comment by peng zhenyi [ 09/Aug/21 ]

Hi tyler.seip and ratika.gandhi, Will the branch v4.0 be backported? 
I have a lot of mongodb v4.0 clusters, so the upgration will be convenient for me and other v4.0 users if the commit is backported to community v4.0 version.
I have created a pull request for v4.0 as mentioned before (modified different files compare to branch master):
v4.0: https://github.com/mongodb/mongo/pull/1402/files

Comment by Githook User [ 03/Aug/21 ]

Author:

{'name': 'Tyler Seip', 'email': 'Tyler.Seip@mongodb.com', 'username': 'tseip-mongo'}

Message: SERVER-55581: Return ScopedDbConnection to connection pool in cluster aggregation planner
Branch: master
https://github.com/mongodb/mongo/commit/663e90bbe862969572246b7b442845ed83a2472d

Comment by Tyler Seip (Inactive) [ 03/Aug/21 ]

I believe the destructor of ScopedDbConnection will return the connection to the pool automatically; see here (note that this hasn't changed since 2015 so it should be in all active versions of Mongo). I don't see any leaked connections here. pengzhenyi, did you notice this because you observed a leak?

Edit: I didn't read that destructor very closely; we can still leak connections. I'll search around for all examples of unclosed connections.

Edit 2: After auditing all of the ScopedDbConnections, this is indeed the only one that doesn't call done() on success. Thanks for finding this pengzhenyi!

Comment by peng zhenyi [ 30/Jun/21 ]

As https://jira.mongodb.org/browse/SERVER-39642 fixed, the egress counter won't increase to a very large value.

But the ScopedDbConnection which can be reused will be destructed.

And that may lead to too much connection's creation and destroy.

Comment by Ratika Gandhi [ 29/Jun/21 ]

We will investigate this in the next few iterations. 

Comment by peng zhenyi [ 28/Jun/21 ]

Hi eric.sedor, it this a bug ? or any other progress here?

Comment by Eric Sedor [ 29/Mar/21 ]

Thanks pengzhenyi, I'm assigning this ticket to an appropriate team to evaluate.

Comment by peng zhenyi [ 28/Mar/21 ]

v4.0 : https://github.com/mongodb/mongo/pull/1402/files

Generated at Thu Feb 08 05:36:52 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.