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

"not master" error from update or remove with lazily-connected MongoClient

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 2.7
    • Affects Version/s: 2.4
    • Component/s: None
    • None

      If a MongoClient is initialized with _connect=False, and the first operation on the client is an update or remove, the client throws AutoReconnect("not master").

      The bug does not manifest if the first operation is an insert, or if the client is a MongoReplicaSetClient.

      The cause is: Collection calls client._ensure_connected(True) before doing an insert or command, but fails to do so before doing an update or remove. If the client is a MongoReplicaSetClient, the client calls self.__find_primary() before attempting to send the message, but MongoClient does not.

      Collection should call _ensure_connected before an update or remove, the same as insert, in order to determine the wire protocol version. In the process, it will also avoid the "not master" error.

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

              Created:
              Updated:
              Resolved: