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

Connection not reused and keep growing

    • Type: Icon: Bug Bug
    • Resolution: Works as Designed
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 2.10.3
    • Component/s: Connectivity
    • None
    • Environment:
      c# driver in Azure VM hosting Service Fabric Cluster

      We have a proces where all our tenant databases are processed. In our setup each tenant has it's own database (with own credentials).

      Currently we use the default of the c# driver (connection pool of 100). What i'm seeing is that the number of connections to our MongoBD server is only increasing.

      It looks like the driver is not reusing used connections from the pool.

      I use the following script

      db.currentOp(true).inprog.reduce(
      {{ (accumulator, connection) => {}}
      {{ ipaddress = connection.client ? connection.client.split(":")[0] : "Internal";}}
      {{ ipaddressActiveConnection = ipaddress + "-active";}}
      {{ ipaddressINActiveConnection = ipaddress + "-INactive"; }}
      {{ accumulator[ipaddress] = (accumulator[ipaddress] || 0) + 1;}}
      {{ accumulator["TOTAL_CONNECTION_COUNT"]++;}}
      {{ if (connection.active) { }}
      {{ accumulator[ipaddressActiveConnection] = (accumulator[ipaddressActiveConnection] || 0) + 1;}}
      {{ accumulator["ACTIVE_CONNECTION_COUNT"]++;}}
      {{ } else {}}
      {{ accumulator[ipaddressINActiveConnection] = (accumulator[ipaddressINActiveConnection] || 0) + 1;}}
      {{ accumulator["INACTIVE_CONNECTION_COUNT"]++;}}
      {{ }}}
      {{ return accumulator;}}
      {{ },}}
      {{ { TOTAL_CONNECTION_COUNT: 0, ACTIVE_CONNECTION_COUNT : 0, INACTIVE_CONNECTION_COUNT : 0 }}}
      )

      When running i see that the number of INACTIVE_CONNECTIONS is increasing.

      and a little later

       

      Is this normal, cause it feels like a bug, where a new connection (from pool) is created instead of reusing an inactive one.

       

        1. image-2020-11-05-10-19-39-946.png
          image-2020-11-05-10-19-39-946.png
          19 kB
        2. image-2020-11-05-10-19-51-989.png
          image-2020-11-05-10-19-51-989.png
          20 kB
        3. image-2020-11-05-12-00-36-118.png
          image-2020-11-05-12-00-36-118.png
          10 kB
        4. image-2020-11-05-12-01-24-890.png
          image-2020-11-05-12-01-24-890.png
          10 kB

            Assignee:
            james.kovacs@mongodb.com James Kovacs
            Reporter:
            dennis@hoefakkr.nl Dennis Hoefakker
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: