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

Secondary server in replica set reports as master/primary in Python but correctly as not master from mongo command line client

    • Type: Icon: Bug Bug
    • Resolution: Works as Designed
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 3.6.1
    • Component/s: API
    • None
    • Environment:
      Hyper-V 2016 hypervisor
      Ubuntu 16.04 LTS virtual machines
      MongoDB version 3.6.3
      Python Mongo Driver 3.6.1
      Python version 2.7.12
      GCC 5.4.0

      After setting up a MongoDB with replica set on Ubuntu 16.04 LTS.

      Installed on the virtual machines is MongoDB 3.6.3 and Mongo Python driver 3.6.1.

      One virtual machine is set as primary, the other is the secondary.

      Bug Description:
      The secondary reports it is the master/primary in the Python API incorrectly.
      In the command line MongoDB client the secondary correctly reports it is not the master.

      The primary correctly reports it is the master/primary in both the Python API and from the command line MongoDB client.

      Environment
      System 1: Primary 9.11.62.217
      System 2: Secondary, priority 0, votes 0, hidden false 9.11.62.216

      Output from the Primary: 9.11.62.217
      ifconfig report:
      eth0    Line enncap:Ethernet HWaddr XX:XXX:XX:XX:XX
                 inet addr: 9.11.62.217

      The bug is reproducable with the following command from the Terminal of the primary. This bug also shows up if connected from the secondary.

      Steps to Reproduce:
      All user input commands are indicated by starting with a '/'.
      All output are indicated by starting with a '>'.
      Output too long to fit in this long is attached as an image and noted in the command list by >Image Attached: <image name>

      /sudo mongo 9.11.62.217:27017
      >MongoDB shell version v3.6.3
      >connecting to: mongodb://9.11.62.217.27017/test
      >MongoDb server has version: 3.6.3
      >rs0:PRIMARY
      /db.isMaster()
      >Image Attached: master ismaster.bmp
      /quit()
      /sudo mongo 9.11.62.216:27017
      >MongoDB shell version v3.6.3
      >connecting to: mongodb://9.11.62.216:27017/test
      >MongoDB server version: 3.6.3
      >rs0:SECONDARY
      /db.isMaster()
      >Image Attached: secondary ismaster.bmp
      /quit()
      /sudo python
      >Python 2.7.12 (default, Dec  4 2017, 14:50:18)
      >[GCC 5.4.0 20160609] on linux2
      /import pymongo
      /from pymongo import MongoClient
      /client = MongoClient(host='9.11.62.216',port=27017,replicaSet='rs0')
      /client.primary
      >(u'9.11.62.217', 27017)
      /client.secondaries
      >set(['9.11.62.216', 27017)])
      /client.is_primary
      >True
      /client.admin.command("isMaster")
      >Image Attached: python secondary ismaster.bmp

        1. master ismaster.bmp
          master ismaster.bmp
          2.05 MB
        2. python secondary ismaster.bmp
          python secondary ismaster.bmp
          731 kB
        3. secondary ismaster.bmp
          secondary ismaster.bmp
          2.02 MB

            Assignee:
            shane.harvey@mongodb.com Shane Harvey
            Reporter:
            msfwashere Michael Fruchtman
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: