[SERVER-15332] cleanupOrphaned deletes a document, and then returns error, when writeConcern references non-existent tagset Created: 19/Sep/14  Updated: 10/Dec/14  Resolved: 26/Sep/14

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

Type: Bug Priority: Minor - P4
Reporter: Jonathan Abrahams Assignee: Randolph Tan
Resolution: Duplicate Votes: 0
Labels: 28qa
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
duplicates SERVER-14567 Implement checkIfWriteConcernCanBeSat... Closed
Related
is related to SERVER-15421 Weird error message format for invali... Closed
Operating System: ALL
Steps To Reproduce:
  • Create a 2 node sharded cluster, with 3 node replica sets
  • Shard a collection and move one chunk to the second shard
  • Create orphan documents on the primary shard (out of range for the shard key)
  • cleanupOrphan with writeConcern.w = "nodc"
Participants:

 Description   

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 })


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