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

range query on shard key incorrectly sends query to extra shard(s)

    • Type: Icon: Bug Bug
    • Resolution: Duplicate
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 2.0.3
    • Component/s: Sharding
    • Labels:
    • Environment:
      ubuntu 10.04 lts, x86_64
    • ALL

      printShardingStatus(true) says a certain range of shard key ids fall within a single shard:

      ...

      { "my_id" : 13165 }

      -->>

      { "my_id" : 13200 }

      on : shard4

      { "t" : 68000, "i" : 0 } { "my_id" : 13200 }

      -->>

      { "my_id" : 13540 }

      on : shard3

      { "t" : 69000, "i" : 0 }

      ...

      i am taking this to mean [13165, 13200) exists on shard4, while [13200, 13540) exist on shard3 based on:

      db.coll.find(

      {my_id:13200}

      ).explain()
      {
      "clusteredType" : "ParallelSort",
      "shards" : {
      "shard3/10.177.210.46:27017,10.177.210.47:27017" : [
      {
      "cursor" : "BtreeCursor my_id_1",
      "nscanned" : 616,
      "nscannedObjects" : 616,
      "n" : 616,
      "millis" : 2,
      "nYields" : 0,
      "nChunkSkips" : 0,
      "isMultiKey" : false,
      "indexOnly" : false,
      "indexBounds" :

      { "my_id" : [ [ 13200, 13200 ] ] }

      }
      ]
      },
      "n" : 616,
      "nChunkSkips" : 0,
      "nYields" : 0,
      "nscanned" : 616,
      "nscannedObjects" : 616,
      "millisTotal" : 2,
      "millisAvg" : 2,
      "numQueries" : 1,
      "numShards" : 1
      }

      therefore i would expect the range query: {"my_id":{"$gte":13165,"$lt":13200}} to be sent only to shard4, however that is not the case:

      db.coll.find({my_id:{'$gte':13165,'$lt':13200}}).explain()
      {
      "clusteredType" : "ParallelSort",
      "shards" : {
      "shard3/10.177.210.46:27017,10.177.210.47:27017" : [
      {
      "cursor" : "BtreeCursor my_id_1",
      "nscanned" : 0,
      "nscannedObjects" : 0,
      "n" : 0,
      "millis" : 0,
      "nYields" : 0,
      "nChunkSkips" : 0,
      "isMultiKey" : false,
      "indexOnly" : false,
      "indexBounds" :

      { "my_id" : [ [ 13165, 13200 ] ] }

      }
      ],
      "shard4/10.176.64.155:27017,10.177.205.133:27017" : [
      {
      "cursor" : "BtreeCursor my_id_1",
      "nscanned" : 9248,
      "nscannedObjects" : 9248,
      "n" : 9248,
      "millis" : 45,
      "nYields" : 0,
      "nChunkSkips" : 0,
      "isMultiKey" : false,
      "indexOnly" : false,
      "indexBounds" :

      { "my_id" : [ [ 13165, 13200 ] ] }

      }
      ]
      },
      "n" : 9248,
      "nChunkSkips" : 0,
      "nYields" : 0,
      "nscanned" : 9248,
      "nscannedObjects" : 9248,
      "millisTotal" : 45,
      "millisAvg" : 22,
      "numQueries" : 2,
      "numShards" : 2
      }

      it should go only to shard4 no?

            Assignee:
            Unassigned Unassigned
            Reporter:
            wayne530 Y. Wayne Huang
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: