The cleanupOrphan deletes the first document if a non-existent tagset is specified in the writeConcern.w
In this case there are no tagsets defined in the replSet configuration.
test-rs0:PRIMARY> db.getSiblingDB("local").system.replset.findOne()
{
"_id" : "test-rs0",
"version" : 1,
"members" : [
{
"_id" : 0,
"host" : "Jonathans-MacBook-Pro.local:31100"
},
{
"_id" : 1,
"host" : "Jonathans-MacBook-Pro.local:31101"
},
{
"_id" : 2,
"host" : "Jonathans-MacBook-Pro.local:31102"
}
]
}
test-rs0:PRIMARY> db.orphan.find({orphan:true}).count();
99
test-rs0:PRIMARY> cd
{
"cleanupOrphaned" : "test.orphan",
"startingAtKey" : {
"shardKey" : 0
},
"secondaryThrottle" : true,
"writeConcern" : {
"w" : "nodc"
}
}
test-rs0:PRIMARY> db.adminCommand(cd);
{
"ok" : 0,
"errmsg" : "Error encountered while deleting range: nstest.orphan from { shardKey: MinKey } -> { shardKey: 500.0 }, cause by: :: caused by :: 79 No write concern mode named \"nodc found in replica set configuration"
}
test-rs0:PRIMARY> db.orphan.find({orphan:true}).count();
98
In this case there are tagsets
test-rs0:PRIMARY> conf=db.getSiblingDB("local").system.replset.findOne()
{
"_id" : "test-rs0",
"version" : 2,
"members" : [
{
"_id" : 0,
"host" : "Jonathans-MacBook-Pro.local:31100",
"priority" : 100,
"tags" : {
"main" : "NY"
}
},
{
"_id" : 1,
"host" : "Jonathans-MacBook-Pro.local:31101",
"priority" : 2,
"tags" : {
"backup" : "SF"
}
},
{
"_id" : 2,
"host" : "Jonathans-MacBook-Pro.local:31102",
"priority" : 2,
"tags" : {
"main" : "NY"
}
}
],
"settings" : {
"getLastErrorModes" : {
"alldc" : {
"main" : 1,
"backup" : 1
},
"maindc" : {
"main" : 1
}
}
}
}
test-rs0:PRIMARY> cd={cleanupOrphaned: "test.orphan", startingAtKey:{shardKey:0}, secondaryThrottle:true, writeConcern: {w: "maindc"}}
test-rs0:PRIMARY> db.adminCommand(cd);
{ "stoppedAtKey" : { "shardKey" : 500 }, "ok" : 1 }
test-rs0:PRIMARY> db.orphan.find({orphan:true}).count();
0
test-rs0:PRIMARY> for (i=0;i<100;i++) { db.orphan.insert({shardKey:i, orphan: true}) }
WriteResult({ "nInserted" : 1 })
test-rs0:PRIMARY> db.orphan.find({orphan:true}).count();
100
test-rs0:PRIMARY> cd={cleanupOrphaned: "test.orphan", startingAtKey:{shardKey:0}, secondaryThrottle:true, writeConcern: {w: "main"}}
test-rs0:PRIMARY> db.adminCommand(cd);
{
"ok" : 0,
"errmsg" : "Error encountered while deleting range: nstest.orphan from { shardKey: MinKey } -> { shardKey: 500.0 }, cause by: :: caused by :: 79 No write concern mode named \"main found in replica set configuration"
}
test-rs0:PRIMARY> db.orphan.find({orphan:true}).count();
99
Note - behavior for an insert with a similar setup is accepted:
test-rs0:PRIMARY> db.orphan.insert({shardKey:200,orphan:true},{w: "nodc"})
WriteResult({ "nInserted" : 1 })
- duplicates
-
SERVER-14567 Implement checkIfWriteConcernCanBeSatisfied
-
- Closed
-
- is related to
-
SERVER-15421 Weird error message format for invalid write concern tag
-
- Closed
-