-
Type:
Improvement
-
Resolution: Done
-
Priority:
Major - P3
-
None
-
Affects Version/s: None
-
Component/s: Replication
-
Fully Compatible
-
(copied to CRM)
-
None
-
None
-
None
-
None
-
None
-
None
-
None
I wanted to set the priority of the current replica set primary to zero. Here's a log of what happened:
PRIMARY> rs.status();
{
"set" : "foo",
"date" : ISODate("2011-09-12T18:48:54Z"),
"myState" : 1,
"members" : [
{
"_id" : 0,
"name" : "localhost:27017",
"health" : 1,
"state" : 1,
"stateStr" : "PRIMARY",
"optime" : {
"t" : 1315530008000,
"i" : 1
},
"optimeDate" : ISODate("2011-09-09T01:00:08Z"),
"self" : true
},
{
"_id" : 1,
"name" : "localhost:27018",
"health" : 1,
"state" : 2,
"stateStr" : "SECONDARY",
"uptime" : 39,
"optime" : {
"t" : 1315530008000,
"i" : 1
},
"optimeDate" : ISODate("2011-09-09T01:00:08Z"),
"lastHeartbeat" : ISODate("2011-09-12T18:48:53Z"),
"pingMs" : 0
},
{
"_id" : 2,
"name" : "localhost:27019",
"health" : 1,
"state" : 2,
"stateStr" : "SECONDARY",
"uptime" : 27,
"optime" : {
"t" : 1315530008000,
"i" : 1
},
"optimeDate" : ISODate("2011-09-09T01:00:08Z"),
"lastHeartbeat" : ISODate("2011-09-12T18:48:53Z"),
"pingMs" : 4
}
],
"ok" : 1
}
PRIMARY> var myconf = rs.conf();
PRIMARY> myconf.members[0].priority = 0;
0
PRIMARY> myconf
{
"_id" : "foo",
"version" : 4,
"members" : [
{
"_id" : 0,
"host" : "localhost:27017",
"priority" : 0
},
{
"_id" : 1,
"host" : "localhost:27018"
},
{
"_id" : 2,
"host" : "localhost:27019"
}
]
}
PRIMARY> rs.reconfig(myconf);
{
"assertion" : "initiation and reconfiguration of a replica set must be s
ent to a node that can become primary",
"assertionCode" : 13420,
"errmsg" : "db assertion failure",
"ok" : 0
}
PRIMARY> exit
bye
cwestin@tellus ~/mongo
$ ./mongo --port 27018
MongoDB shell version: 2.1.0-pre-
connecting to: 127.0.0.1:27018/test
SECONDARY> var myconf = rs.conf();
SECONDARY> myconf.members[0].priority = 0;
0
SECONDARY> myconf
{
"_id" : "foo",
"version" : 4,
"members" : [
{
"_id" : 0,
"host" : "localhost:27017",
"priority" : 0
},
{
"_id" : 1,
"host" : "localhost:27018"
},
{
"_id" : 2,
"host" : "localhost:27019"
}
]
}
SECONDARY> rs.reconfig(myconf);
{
"errmsg" : "replSetReconfig command must be sent to the current replica
set primary.",
"ok" : 0
}
SECONDARY>
You can't set the priority of the current primary to zero because you can only send reconfigure commands to a node that can become primary? That appears to be failing because the result would cause the node to no longer be able to become primary. But you can't send the same thing to a secondary either, even though it could become primary.
You can work around this by asking the original primary to step down, and then issuing the appropriate priority request to the new primary.
However, the priority change here pretty much amounts to a permanent stepDown() request, so it seems like it should work on the primary; if it can step down, this should be doable.