Uploaded image for project: 'Python Driver'
  1. Python Driver
  2. PYTHON-732

Rare connection pool leak after network error with auth

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major - P3
    • Resolution: Fixed
    • 2.6
    • 2.7.2
    • None
    • None
    • Fully Compatible

    Description

      A socket is leaked and forever counts against max_pool_size in the following scenario:

      1. MongoClient has at least two sockets in the pool, sockets A and B.
      2. The client successfully calls authenticate() on socket A, and adds a credential to its credentials-cache.
      3. The client checks socket B out of the pool, sees that B lacks the new credential, and authenticates on B.
      4. Socket B raises a network error during authentication.

      Two incorrect behaviors now occur:

      • MongoClient throws a socket.error instead of AutoReconnect
      • The socket is leaked and the max_pool_size semaphore is never incremented

      The coding errors are in MongoClient.__simple_command, where a socket.error should be translated into AutoReconnect, and in MongoClient.__socket, which returns the socket only after OperationFailure, but should do so after any exception.

      MongoReplicaSetClient has neither bug.

      MongoClient and its predecessor Connection have never returned the socket to the pool after a network error in this code path, nor translated socket.error into AutoReconnect. The behavior became a major bug in PyMongo 2.6 with the PYTHON-436 feature. Beginning then, the pool enforced max_pool_size and it became critical to close and return sockets after network errors.

      Attachments

        Issue Links

          Activity

            People

              jesse@mongodb.com A. Jesse Jiryu Davis
              jesse@mongodb.com A. Jesse Jiryu Davis
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: