Uploaded image for project: 'C# Driver'
  1. C# Driver
  2. CSHARP-2861

Having incorrect credentials along with minPoolSize > 0 makes the driver to endlessly create new connections

    XMLWordPrintableJSON

Details

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Major - P3 Major - P3
    • 2.10.1
    • 2.8.1
    • Connectivity
    • None

    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.

      Attachments

        Activity

          People

            dmitry.lukyanov@mongodb.com Dmitry Lukyanov (Inactive)
            dmitry.ryabtsev@mongodb.com Dmitry Ryabtsev
            Votes:
            0 Vote for this issue
            Watchers:
            7 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: