[SERVER-13055] Shouldn't allow w:0 in replset getLastErrorDefaults Created: 05/Mar/14  Updated: 11/Jul/16  Resolved: 29/Oct/14

Status: Closed
Project: Core Server
Component/s: Replication
Affects Version/s: 2.6.0-rc0
Fix Version/s: 2.7.2

Type: Improvement Priority: Major - P3
Reporter: Mathias Stearn Assignee: Matt Dannenberg
Resolution: Done Votes: 0
Labels: 26qa, cap-ticket-needed, repl1
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
related to SERVER-15623 Test that w:0 is prohibited in getLas... Closed
is related to SERVER-15655 Secondary can't join if w:0 is in get... Closed
is related to SERVER-15859 Don't allow w:0 in getLastErrorDefaul... Closed
is related to SERVER-13056 Write commands should ignore w:0 when... Closed
is related to SERVER-18407 Ensure getLastErrorDefaults/getLastEr... Closed
Tested
Participants:

 Description   

Example showing it is currently allowed:

> rs.initiate()
{
        "info2" : "no configuration explicitly specified -- making one",
        "me" : "redbeard:27017",
        "info" : "Config now saved locally.  Should come online in about a minute.",
        "ok" : 1
}
foo:PRIMARY> conf = rs.conf()
{
        "_id" : "foo",
        "version" : 1,
        "members" : [
                {
                        "_id" : 0,
                        "host" : "redbeard:27017"
                }
        ]
}
foo:PRIMARY> conf.settings = {getLastErrorDefaults: {w:0}}
{ "getLastErrorDefaults" : { "w" : 0 } }
foo:PRIMARY> conf
{
        "_id" : "foo",
        "version" : 1,
        "members" : [
                {
                        "_id" : 0,
                        "host" : "redbeard:27017"
                }
        ],
        "settings" : {
                "getLastErrorDefaults" : {
                        "w" : 0
                }
        }
}
foo:PRIMARY> rs.reconfig(conf)
{ "ok" : 1 }
foo:PRIMARY> rs.conf()
{
        "_id" : "foo",
        "version" : 2,
        "members" : [
                {
                        "_id" : 0,
                        "host" : "redbeard:27017"
                }
        ],
        "settings" : {
                "getLastErrorDefaults" : {
                        "w" : 0
                }
        }
}



 Comments   
Comment by Spencer Brody (Inactive) [ 29/Oct/14 ]

This was fixed in the legacy code in 2.7.2, opened SERVER-15859 to track adding this check to the new replication code.

Comment by A. Jesse Jiryu Davis [ 28/Oct/14 ]

On a recent build (589a52d8e) I can use replSetReconfig to put {w: 0} in getLastErrorDefaults. I think this was prohibited, as desired, earlier, but that it's regressed. I'm not certain though.

I start one mongod:

./mongod --nojournal --dbpath data --replSet rs

In the shell:

> use admin
switched to db admin
> rs.initiate({_id: 'rs', members: [{_id: 0, host: 'localhost:27017'}]})
{ "ok" : 1 }
rs:OTHER>
rs:PRIMARY> var conf = db.runCommand({replSetGetConfig: 1}).config;
rs:PRIMARY> conf
{
	"_id" : "rs",
	"version" : 1,
	"members" : [
		{
			"_id" : 0,
			"host" : "localhost:27017",
			"arbiterOnly" : false,
			"buildIndexes" : true,
			"hidden" : false,
			"priority" : 1,
			"tags" : {
 
			},
			"slaveDelay" : 0,
			"votes" : 1
		}
	],
	"settings" : {
		"chainingAllowed" : true,
		"heartbeatTimeoutSecs" : 10,
		"getLastErrorModes" : {
 
		},
		"getLastErrorDefaults" : {
			"w" : 1,
			"wtimeout" : 0
		}
	}
}
rs:PRIMARY> conf.settings = {getLastErrorDefaults: {w: 0}}
{ "getLastErrorDefaults" : { "w" : 0 } }
rs:PRIMARY> conf.version++
1
rs:PRIMARY> db.runCommand({replSetReconfig: conf})
{ "ok" : 1 }
rs:PRIMARY> db.runCommand({replSetGetConfig: 1}).config
{
	"_id" : "rs",
	"version" : 2,
	"members" : [
		{
			"_id" : 0,
			"host" : "localhost:27017",
			"arbiterOnly" : false,
			"buildIndexes" : true,
			"hidden" : false,
			"priority" : 1,
			"tags" : {
 
			},
			"slaveDelay" : 0,
			"votes" : 1
		}
	],
	"settings" : {
		"chainingAllowed" : true,
		"heartbeatTimeoutSecs" : 10,
		"getLastErrorModes" : {
 
		},
		"getLastErrorDefaults" : {
			"w" : 0,
			"wtimeout" : 0
		}
	}
}
rs:PRIMARY> db.serverBuildInfo()
{
	"version" : "2.7.9-pre-",
	"gitVersion" : "589a52d8e966cd11b568038fadb4a27c3ffbe835",
        ...
}

Comment by A. Jesse Jiryu Davis [ 14/Oct/14 ]

OK, I've opened SERVER-15655 to track what I observe. We can discuss there what the desired behavior is.

Comment by Matt Dannenberg [ 13/Oct/14 ]

redbeard0531 hasn't been working on replication. Better to pull in schwerin and milkie instead. I believe the correct answer is the 2.8 mongod will refuse to start up. If the node is already up, it should go into the REMOVED state. Will confirm tomorrow.

Comment by A. Jesse Jiryu Davis [ 13/Oct/14 ]

redbeard0531 and mattd@10gen.com, what's the expected behavior if I configure a 2.6 replica set with getLastErrorDefaults w:0, then upgrade to 2.8? How about if the current primary is 2.6 and secondaries are 2.8, and I issue a replicaSetReconfig to the primary with getLastErrorDefaults w:0?

Comment by Githook User [ 03/Jun/14 ]

Author:

{u'username': u'dannenberg', u'name': u'matt dannenberg', u'email': u'matt.dannenberg@10gen.com'}

Message: SERVER-13055 disallow w:0 as getLastErrorDefaults value
Branch: master
https://github.com/mongodb/mongo/commit/af057b64bad3fff652b98137e66dd138833d46c0

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