[SERVER-3815] replica sets: can't set priority of current primary to zero Created: 12/Sep/11  Updated: 23/Apr/18  Resolved: 05/Feb/15

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

Type: Improvement Priority: Major - P3
Reporter: Daniel Pasette (Inactive) Assignee: Matt Dannenberg
Resolution: Done Votes: 1
Labels: elections
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
related to DOCS-1120 improve example to change priority of... Closed
Backwards Compatibility: Fully Compatible
Participants:
Case:

 Description   

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.



 Comments   
Comment by Matt Dannenberg [ 05/Feb/15 ]

The ValidateConfigForReconfig test SelfMustEndElectable in mongo/db/repl/replica_set_config_checks_test.cpp checks that it is not possible without force and is possible with force. Resolving as gone away.

Comment by Eric Milkie [ 29/Jan/15 ]

mattd@10gen.com can you check if force-reconfig on 3.0 now permits this?

Comment by Andy Schwerin [ 27/Oct/14 ]

jesse, can you re-test this with 2.7.8 using a "force" reconfig? Non-force reconfigs intentionally prohibit this behavior, but force should allow it.

Comment by A. Jesse Jiryu Davis [ 02/Sep/14 ]

The behavior persists with the current code:

repl0:PRIMARY> db.serverBuildInfo().gitVersion
e4c72a04f7dab7ab747f59306cabd36cff3f3e16
repl0:PRIMARY> rs.reconfig(myconf)
{
	"ok" : 0,
	"errmsg" : "initiation and reconfiguration of a replica set must be sent to a node that can become primary",
	"code" : 13420
}

Comment by Kristina Chodorow (Inactive) [ 12/Sep/11 ]

I think this check is just a holdover from the extremely paranoid reconfig checks replica sets originally had. I think it makes sense to get rid of it, especially now that priorities other than 0 and 1 are now supported.

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