Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-15332

cleanupOrphaned deletes a document, and then returns error, when writeConcern references non-existent tagset

    • Type: Icon: Bug Bug
    • Resolution: Duplicate
    • Priority: Icon: Minor - P4 Minor - P4
    • None
    • Affects Version/s: 2.7.6
    • Component/s: Sharding
    • Labels:
    • ALL
    • Hide
      • 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"
      Show
      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"

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

            Assignee:
            randolph@mongodb.com Randolph Tan
            Reporter:
            jonathan.abrahams Jonathan Abrahams
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: