[CSHARP-2861] Having incorrect credentials along with minPoolSize > 0 makes the driver to endlessly create new connections Created: 26/Nov/19  Updated: 28/Oct/23  Resolved: 13/Dec/19

Status: Closed
Project: C# Driver
Component/s: Connectivity
Affects Version/s: 2.8.1
Fix Version/s: 2.10.1

Type: Bug Priority: Major - P3
Reporter: Dmitry Ryabtsev Assignee: Dmitry Lukyanov (Inactive)
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
is duplicated by CSHARP-2029 High CPU utilization when specifying ... Closed
Case:

 Description   

This is a simple code that I've used to reproduce the problem in my environment:

using System;
using MongoDB.Driver;
using System.Threading;
 
namespace poolTest
{
    class Program
    {
        // Credentials are deliberately incorrect
        static String uri = "mongodb://adminX:123@mubuntu:27017/test?authSource=admin&minPoolSize=10";
        // static String uri = "mongodb://adminX:123@mubuntu:27017/test?authSource=admin";
        static void Main(string[] args)
        {
            try {
                Console.WriteLine("Connecting....");
                var client = new MongoClient(uri);
 
                Thread.Sleep(500000);
 
            } catch (Exception e) {
                Console.WriteLine("Exception caught {0}", e.Message);
            }
 
        }
    }
}

If minPoolSize is not set, there is no issue. However, if it is set, then the driver just keeps opening new connections over and over again even though the authentication fails for each of those. The connections remain open until MongoClient instance is not destroyed.

This is a problem because a simple mistake in credentials can cause the application to exhaust all of the available connections on the server.



 Comments   
Comment by Githook User [ 12/Dec/19 ]

Author:

{'name': 'DmitryLukyanov', 'email': 'dmitry.lukyanov@mongodb.com', 'username': 'DmitryLukyanov'}

Message: CSHARP-2861: Having incorrect credentials along with minPoolSize > 0 makes the driver to endlessly create new connections.
Branch: master
https://github.com/mongodb/mongo-csharp-driver/commit/9a88686cde8b58c172673fb520fe2816e97ef869

Comment by Dmitry Ryabtsev [ 26/Nov/19 ]

No, it does not.

Comment by Jeffrey Yemin [ 26/Nov/19 ]

Does it close each socket after the authentication attempt fails?

Generated at Wed Feb 07 21:43:43 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.