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

Simplify MasterSlaveConnection configuration

    • Type: Icon: Improvement Improvement
    • Resolution: Duplicate
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 2.0
    • Component/s: None
    • Labels:
      None
    • Environment:
      python2.6, up to pymongo2.0
    • Fully Compatible

      Give more simple way to configure MasterSlaveConnection just like Connection object.

      1. Developer can simply provide replica set nodes to MasterSlaveConnection, MasterSlaveConnection itself determine which one is master, and which ones are slaves.
      2. When Master is down, MasterSlaveConnection raise AutoReconnect upon next write request, and find new master in slave nodes and use it as slave.
      3. If all slaves are down, MasterSlaveConnection will route all read operations to master, until one of them recovered.

      e.g: Server A is master, B, C is slave, D is hidden.
      conn = MasterSlaveConnection(nodes="A:27017,B:27017,C:27017")
      conn.master # --> A
      conn.slaves # --> [B, C]

      1. A is down, B become master
        conn.test.foo.insert( {'bar':1}

        ) # --> AutoReconnect
        conn.test.foo.insert(

        {'bar':1}

        ) # --> find new master in slaves, find that B is master, so route write operation to B, and success.
        conn.master # --> B
        conn.slaves # --> [A, C]
        conn.test.foo.find() # --> Route to C

      1. A recovered
        conn.test.foo.find() # --> Route to A or C
      1. A, C are down
        conn.test.foo.find() # --> Route to B
      1. A, C recovers again.
        conn.test.foo.find() # --> Route to A or C

            Assignee:
            bernie@mongodb.com Bernie Hackett
            Reporter:
            albert Albert Zhong
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: