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

Frequent connection errors result in a Connect/Disconnect storm

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 1.2
    • Affects Version/s: 1.1
    • Component/s: None
    • Labels:

      Currently the C# driver closes all connections in the connection pool whenever an error occurs on any connection. This makes sense in a few cases (for example, the server went away), but in many cases it just makes things worse by causing a Connect/Disconnect storm where connections don't live for very long.

      Furthermore, since Disconnect closes sockets as a background task, it is possible under heavy load to open connections faster than they are being closed, which can overwhelm the server.

      This condition is triggered automatically by high exception rates under load, or can also be triggered by the user code itself by calling Disconnect frequently (some developers have erroneously assumed it is necessary to call Connect and Disconnect around every database operation).

      The easiest way to tell if this is happening to you is to examine the server logs for frequent "end connection" log entries.

      The driver should be very conservative about ever closing all the connections in the connection pool. It should only do so when it can be 100% certain that all connections are doomed and are going to fail anyway (at the moment I'm not sure how we could be 100% sure, so we might just stop doing this).

            robert@mongodb.com Robert Stam
            robert@mongodb.com Robert Stam
            1 Vote for this issue
            1 Start watching this issue