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

MongoDB does not raise an exception when creating tags with overlapping ranges.

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Duplicate
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: Sharding
    • Labels:
      None
    • Backwards Compatibility:
      Fully Compatible
    • Operating System:
      ALL
    • Steps To Reproduce:
      Hide

      Laptop:tmp user$ mongo
      MongoDB shell version: 3.2.0
      connecting to: test
      mongos> use test
      switched to db test
      mongos> db.mycol.ensureIndex( { id : 1 }, { unique : true })
      {
      	"raw" : {
      		"shard01/Laptop.local:27018,Laptop.local:27019,Laptop.local:27020" : {
      			"createdCollectionAutomatically" : true,
      			"numIndexesBefore" : 1,
      			"numIndexesAfter" : 2,
      			"ok" : 1,
      			"$gleStats" : {
      				"lastOpTime" : Timestamp(1452269862, 2),
      				"electionId" : ObjectId("568fe0d80000000000000001")
      			}
      		}
      	},
      	"ok" : 1
      }
      mongos> sh.enableSharding('test');
      { "ok" : 1 }
      mongos> sh.shardCollection('test.mycol', {id: 1});
      { "collectionsharded" : "test.mycol", "ok" : 1 }
      mongos> sh.startBalancer()
      mongos> 
      mongos> sh.getBalancerState()
      true
      mongos> 
      mongos> sh.isBalancerRunning()
      false
      mongos> 
      mongos> sh.status()
      --- Sharding Status --- 
        sharding version: {
      	"_id" : 1,
      	"minCompatibleVersion" : 5,
      	"currentVersion" : 6,
      	"clusterId" : ObjectId("568fe0cf098724379302dda5")
      }
        shards:
      	{  "_id" : "shard01",  "host" : "shard01/Laptop.local:27018,Laptop.local:27019,Laptop.local:27020" }
      	{  "_id" : "shard02",  "host" : "shard02/Laptop.local:27021,Laptop.local:27022,Laptop.local:27023" }
      	{  "_id" : "shard03",  "host" : "shard03/Laptop.local:27024,Laptop.local:27025,Laptop.local:27026" }
        active mongoses:
      	"3.2.0" : 1
        balancer:
      	Currently enabled:  yes
      	Currently running:  no
      	Failed balancer rounds in last 5 attempts:  0
      	Migration Results for the last 24 hours: 
      		No recent migrations
        databases:
      	{  "_id" : "test",  "primary" : "shard01",  "partitioned" : true }
      		test.mycol
      			shard key: { "id" : 1 }
      			unique: false
      			balancing: true
      			chunks:
      				shard01	1
      			{ "id" : { "$minKey" : 1 } } -->> { "id" : { "$maxKey" : 1 } } on : shard01 Timestamp(1, 0) 
       
      mongos> sh.addShardTag('shard01', 'TAG1');
      mongos> sh.addShardTag('shard02', 'TAG2');
      mongos> sh.addShardTag('shard03', 'TAG2');
      mongos> 
      mongos> sh.addTagRange('shard01', {id: 1}, {id: 200}, 'TAG1');
      mongos> sh.addTagRange('shard01', {id: 100}, {id: 150}, 'TAG2');
      mongos> sh.addTagRange('shard01', {id: 0}, {id: 300}, 'TAG2');
      mongos> 
      mongos> use config
      switched to db config
      mongos> db.tags.find()
      { "_id" : { "ns" : "shard01", "min" : { "id" : 1 } }, "ns" : "shard01", "min" : { "id" : 1 }, "max" : { "id" : 200 }, "tag" : "TAG1" }
      { "_id" : { "ns" : "shard01", "min" : { "id" : 100 } }, "ns" : "shard01", "min" : { "id" : 100 }, "max" : { "id" : 150 }, "tag" : "TAG2" }
      { "_id" : { "ns" : "shard01", "min" : { "id" : 0 } }, "ns" : "shard01", "min" : { "id" : 0 }, "max" : { "id" : 300 }, "tag" : "TAG2" }
      mongos> 
      

      We now have three overlapping ranges with two different TAGs.

      No errors were raised. The intended location of a chunk with "id" values from 110 => 125 appears to be ambiguous, and the expected behaviour of the balancer undefined.

      Show
      Laptop:tmp user$ mongo MongoDB shell version: 3.2.0 connecting to: test mongos> use test switched to db test mongos> db.mycol.ensureIndex( { id : 1 }, { unique : true }) { "raw" : { "shard01/Laptop.local:27018,Laptop.local:27019,Laptop.local:27020" : { "createdCollectionAutomatically" : true, "numIndexesBefore" : 1, "numIndexesAfter" : 2, "ok" : 1, "$gleStats" : { "lastOpTime" : Timestamp(1452269862, 2), "electionId" : ObjectId("568fe0d80000000000000001") } } }, "ok" : 1 } mongos> sh.enableSharding('test'); { "ok" : 1 } mongos> sh.shardCollection('test.mycol', {id: 1}); { "collectionsharded" : "test.mycol", "ok" : 1 } mongos> sh.startBalancer() mongos> mongos> sh.getBalancerState() true mongos> mongos> sh.isBalancerRunning() false mongos> mongos> sh.status() --- Sharding Status --- sharding version: { "_id" : 1, "minCompatibleVersion" : 5, "currentVersion" : 6, "clusterId" : ObjectId("568fe0cf098724379302dda5") } shards: { "_id" : "shard01", "host" : "shard01/Laptop.local:27018,Laptop.local:27019,Laptop.local:27020" } { "_id" : "shard02", "host" : "shard02/Laptop.local:27021,Laptop.local:27022,Laptop.local:27023" } { "_id" : "shard03", "host" : "shard03/Laptop.local:27024,Laptop.local:27025,Laptop.local:27026" } active mongoses: "3.2.0" : 1 balancer: Currently enabled: yes Currently running: no Failed balancer rounds in last 5 attempts: 0 Migration Results for the last 24 hours: No recent migrations databases: { "_id" : "test", "primary" : "shard01", "partitioned" : true } test.mycol shard key: { "id" : 1 } unique: false balancing: true chunks: shard01 1 { "id" : { "$minKey" : 1 } } -->> { "id" : { "$maxKey" : 1 } } on : shard01 Timestamp(1, 0)   mongos> sh.addShardTag('shard01', 'TAG1'); mongos> sh.addShardTag('shard02', 'TAG2'); mongos> sh.addShardTag('shard03', 'TAG2'); mongos> mongos> sh.addTagRange('shard01', {id: 1}, {id: 200}, 'TAG1'); mongos> sh.addTagRange('shard01', {id: 100}, {id: 150}, 'TAG2'); mongos> sh.addTagRange('shard01', {id: 0}, {id: 300}, 'TAG2'); mongos> mongos> use config switched to db config mongos> db.tags.find() { "_id" : { "ns" : "shard01", "min" : { "id" : 1 } }, "ns" : "shard01", "min" : { "id" : 1 }, "max" : { "id" : 200 }, "tag" : "TAG1" } { "_id" : { "ns" : "shard01", "min" : { "id" : 100 } }, "ns" : "shard01", "min" : { "id" : 100 }, "max" : { "id" : 150 }, "tag" : "TAG2" } { "_id" : { "ns" : "shard01", "min" : { "id" : 0 } }, "ns" : "shard01", "min" : { "id" : 0 }, "max" : { "id" : 300 }, "tag" : "TAG2" } mongos> We now have three overlapping ranges with two different TAGs. No errors were raised. The intended location of a chunk with "id" values from 110 => 125 appears to be ambiguous, and the expected behaviour of the balancer undefined.
    • Sprint:
      Sharding 17 (07/15/16), Sharding 18 (08/05/16)

      Description

      The MongoDB Reference Manual states:

      To assign a tag to a range of shard keys use the sh.addTagRange() method when connected to a mongos instance. Any given shard key range may only have one assigned tag. You cannot overlap defined ranges, or tag the same range more than once.

      In mongodb 3.2,0, it is possible to create tags with overlapping ranges. No errors are raised, and the overlapping tags are created. (Exception: in the case where two overlapping ranges have the same lower bound, the second range definition replaces the first.) Hereafter, the documentation does not define the behaviour of the balancer, when a single chunk may be considered to belong to more than one tag.

        Attachments

          Issue Links

            Activity

              People

              • Votes:
                0 Vote for this issue
                Watchers:
                7 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: