[SERVER-3413] moveprimary doesn't propagate changes to other mongos instances Created: 11/Jul/11  Updated: 06/Mar/13  Resolved: 17/May/12

Status: Closed
Project: Core Server
Component/s: Sharding
Affects Version/s: 1.8.2
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Bryon Ross Assignee: Unassigned
Resolution: Duplicate Votes: 3
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
Duplicate
duplicates SERVER-3562 moveprimary moves all databases, incl... Closed
Operating System: ALL
Participants:

 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.



 Comments   
Comment by James Blackburn [ 06/Mar/13 ]

When was this fixed? I saw this on 2.2.1:
https://jira.mongodb.org/browse/SERVER-8870

Comment by Jon Ivmark [ 19/Oct/11 ]

This caused me some pain the other day (using 1.8.3). Would be really nice if it was fixed.

Generated at Thu Feb 08 03:02:59 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.