Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-3413

moveprimary doesn't propagate changes to other mongos instances

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Duplicate
    • Affects Version/s: 1.8.2
    • Fix Version/s: None
    • Component/s: Sharding
    • Labels:
      None
    • Operating System:
      ALL

      Description

      After running the moveprimary command via mongos, other mongos instances that communicate with the same mongod instances may not be aware of the move. In other words, they may still send updates to the old mongod after the move is complete.

      Steps to reproduce:
      Assume there are

      • two mongod instances running on ports 27101 and 27102
      • two mongos instances running on ports 27017 and 27018
      • one config server instance running on port 27019

      1) Open a mongo shell to each of the two mongos instances (db=test).
      2) Call db.stats() on each shell.
      3) On the first mongos, move the test database to the other shard.
      4) Call db.stats() on each shell. Note that the second mongos returns the wrong primary.

      SHELL 1:
      ...>mongo localhost:27017
      MongoDB shell version: 1.8.2
      connecting to: localhost:27017/test
      > db.stats()
      {
      "raw" : {
      "localhost:27101" :

      { "db" : "test", "collections" : 0, "objects" : 0, "avgObjSize" : 0, "dataSize" : 0, "storageSize" : 0, "numExtents" : 0, "indexes" : 0, "indexSize" : 0, "fileSize" : 0, "ok" : 1 }

      },
      "objects" : 0,
      "avgObjSize" : NaN,
      "dataSize" : 0,
      "storageSize" : 0,
      "numExtents" : 0,
      "indexes" : 0,
      "indexSize" : 0,
      "fileSize" : 0,
      "ok" : 1
      }

      SHELL 2:
      ...>mongo localhost:27018
      MongoDB shell version: 1.8.2
      connecting to: localhost:27018/test
      > db.stats()
      {
      "raw" : {
      "localhost:27101" :

      { "db" : "test", "collections" : 0, "objects" : 0, "avgObjSize" : 0, "dataSize" : 0, "storageSize" : 0, "numExtents" : 0, "indexes" : 0, "indexSize" : 0, "fileSize" : 0, "ok" : 1 }

      },
      "objects" : 0,
      "avgObjSize" : NaN,
      "dataSize" : 0,
      "storageSize" : 0,
      "numExtents" : 0,
      "indexes" : 0,
      "indexSize" : 0,
      "fileSize" : 0,
      "ok" : 1
      }

      SHELL 1:
      > db.adminCommand(

      {moveprimary: "test", to: "localhost:27102"}

      )

      { "primary " : "shard0001:localhost:27102", "ok" : 1 }

      > db.stats()
      {
      "raw" : {
      "localhost:27102" :

      { "db" : "test", "collections" : 0, "objects" : 0, "avgObjSize" : 0, "dataSize" : 0, "storageSize" : 0, "numExtents" : 0, "indexes" : 0, "indexSize" : 0, "fileSize" : 0, "ok" : 1 }

      },
      "objects" : 0,
      "avgObjSize" : NaN,
      "dataSize" : 0,
      "storageSize" : 0,
      "numExtents" : 0,
      "indexes" : 0,
      "indexSize" : 0,
      "fileSize" : 0,
      "ok" : 1
      }
      > db.test.insert({_id:"bob", value: 1});

      SHELL 2:
      > db.stats()
      {
      "raw" : {
      "localhost:27101" :

      { "db" : "test", "collections" : 0, "objects" : 0, "avgObjSize" : 0, "dataSize" : 0, "storageSize" : 0, "numExtents" : 0, "indexes" : 0, "indexSize" : 0, "fileSize" : 0, "ok" : 1 }

      },
      "objects" : 0,
      "avgObjSize" : NaN,
      "dataSize" : 0,
      "storageSize" : 0,
      "numExtents" : 0,
      "indexes" : 0,
      "indexSize" : 0,
      "fileSize" : 0,
      "ok" : 1
      }
      > db.test.insert({_id:"bob", value: 2});

      Note that if you restart the second mongos at this point, the document {_id:"bob", value: 2} is lost forever, as it was persisted on the wrong mongod.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              Unassigned Unassigned
              Reporter:
              bross@playdom.com Bryon Ross
              Participants:
              Votes:
              3 Vote for this issue
              Watchers:
              6 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: