updateZoneKeyRange is inconsistent with updating and deleting tags when tag ranges are prefix for shard key

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Duplicate
    • Priority: Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • None
    • Sharding
    • ALL
    • Hide
      mongos> sh.shardCollection("test.c" , {a: 1, b: 1})
      {
          "collectionsharded" : "test.c",
          "collectionUUID" : UUID("5c33de36-7f4a-4cc0-bdf1-b8101a7d34b1"),
          "ok" : 1,
          "operationTime" : Timestamp(1573048485, 13),
          "$clusterTime" : {
              "clusterTime" : Timestamp(1573048485, 13),
              "signature" : {
                  "hash" : BinData(0,"AAAAAAAAAAAAAAAAAAAAAAAAAAA="),
                  "keyId" : NumberLong(0)
              }
          }
      }
      mongos> use admin
      mongos> sh.addShardToZone("shard01", "zone1")
      {
          "ok" : 1,
          "operationTime" : Timestamp(1573048597, 1),
          "$clusterTime" : {
              "clusterTime" : Timestamp(1573048597, 1),
              "signature" : {
                  "hash" : BinData(0,"AAAAAAAAAAAAAAAAAAAAAAAAAAA="),
                  "keyId" : NumberLong(0)
              }
          }
      }
      mongos> db.runCommand({updateZoneKeyRange: "test.c" , min : {a: 1}, max: {a: 2}, zone: "zone1"}) 
      {
          "ok" : 1,
          "operationTime" : Timestamp(1573048606, 8),
          "$clusterTime" : {
              "clusterTime" : Timestamp(1573048606, 8),
              "signature" : {
                  "hash" : BinData(0,"AAAAAAAAAAAAAAAAAAAAAAAAAAA="),
                  "keyId" : NumberLong(0)
              }
          }
      }
      
      mongos> db.runCommand({updateZoneKeyRange: "test.c" , min : {a: 1}, max: {a: 2}, zone: null}) // Command succeeds but doesn't delete the tag range.
      {
          "ok" : 1,
          "operationTime" : Timestamp(1573049199, 1),
          "$clusterTime" : {
              "clusterTime" : Timestamp(1573049199, 1),
              "signature" : {
                  "hash" : BinData(0,"AAAAAAAAAAAAAAAAAAAAAAAAAAA="),
                  "keyId" : NumberLong(0)
              }
          }
      }
      mongos> db.getSiblingDB("config").tags.find()
      { "_id" : ObjectId("5dc2d11e8bc365c6f4466713"), "ns" : "test.c", "min" : { "a" : 1, "b" : { "$minKey" : 1 } }, "max" : { "a" : 2, "b" : { "$minKey" : 1 } }, "tag" : "zone1" }
      mongos> db.runCommand({updateZoneKeyRange: "test.c" , min : {a: 1, b: MinKey}, max: {a: 2, b: MinKey}, zone: null}) // Deletes the tag range.
      {
      	"ok" : 1,
      	"operationTime" : Timestamp(1573049663, 1),
      	"$clusterTime" : {
      		"clusterTime" : Timestamp(1573049663, 1),
      		"signature" : {
      			"hash" : BinData(0,"AAAAAAAAAAAAAAAAAAAAAAAAAAA="),
      			"keyId" : NumberLong(0)
      		}
      	}
      }
      mongos> db.getSiblingDB("config").tags.find({min: {a: 1, b : MinKey}})
      mongos>
      
      Show
      mongos> sh.shardCollection( "test.c" , {a: 1, b: 1}) { "collectionsharded" : "test.c" , "collectionUUID" : UUID( "5c33de36-7f4a-4cc0-bdf1-b8101a7d34b1" ), "ok" : 1, "operationTime" : Timestamp(1573048485, 13), "$clusterTime" : { "clusterTime" : Timestamp(1573048485, 13), "signature" : { "hash" : BinData(0, "AAAAAAAAAAAAAAAAAAAAAAAAAAA=" ), "keyId" : NumberLong(0) } } } mongos> use admin mongos> sh.addShardToZone( "shard01" , "zone1" ) { "ok" : 1, "operationTime" : Timestamp(1573048597, 1), "$clusterTime" : { "clusterTime" : Timestamp(1573048597, 1), "signature" : { "hash" : BinData(0, "AAAAAAAAAAAAAAAAAAAAAAAAAAA=" ), "keyId" : NumberLong(0) } } } mongos> db.runCommand({updateZoneKeyRange: "test.c" , min : {a: 1}, max: {a: 2}, zone: "zone1" }) { "ok" : 1, "operationTime" : Timestamp(1573048606, 8), "$clusterTime" : { "clusterTime" : Timestamp(1573048606, 8), "signature" : { "hash" : BinData(0, "AAAAAAAAAAAAAAAAAAAAAAAAAAA=" ), "keyId" : NumberLong(0) } } } mongos> db.runCommand({updateZoneKeyRange: "test.c" , min : {a: 1}, max: {a: 2}, zone: null }) // Command succeeds but doesn't delete the tag range. { "ok" : 1, "operationTime" : Timestamp(1573049199, 1), "$clusterTime" : { "clusterTime" : Timestamp(1573049199, 1), "signature" : { "hash" : BinData(0, "AAAAAAAAAAAAAAAAAAAAAAAAAAA=" ), "keyId" : NumberLong(0) } } } mongos> db.getSiblingDB( "config" ).tags.find() { "_id" : ObjectId( "5dc2d11e8bc365c6f4466713" ), "ns" : "test.c" , "min" : { "a" : 1, "b" : { "$minKey" : 1 } }, "max" : { "a" : 2, "b" : { "$minKey" : 1 } }, "tag" : "zone1" } mongos> db.runCommand({updateZoneKeyRange: "test.c" , min : {a: 1, b: MinKey}, max: {a: 2, b: MinKey}, zone: null }) // Deletes the tag range. { "ok" : 1, "operationTime" : Timestamp(1573049663, 1), "$clusterTime" : { "clusterTime" : Timestamp(1573049663, 1), "signature" : { "hash" : BinData(0, "AAAAAAAAAAAAAAAAAAAAAAAAAAA=" ), "keyId" : NumberLong(0) } } } mongos> db.getSiblingDB( "config" ).tags.find({min: {a: 1, b : MinKey}}) mongos>
    • None
    • 3
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      If we define a tag range based prefix of a shard key, the updateZoneKeyRange command fills in 'MinKey' for all the missing shard key fields when updating a tag range. But it doesn't do that when deleting. Users would have to specify the full shard key by adding in 'MinKey' for the missing fields.

      It would be helpful if the docs for updateZoneKeyRange also mentions this.

            Assignee:
            [DO NOT USE] Backlog - Sharding Team
            Reporter:
            Arun Banala
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: