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

querying with hashed borders broke in 2.6

    XMLWordPrintableJSON

Details

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major - P3 Major - P3
    • None
    • 2.6.0, 2.6.1, 2.6.2, 2.6.3
    • Querying, Sharding
    • None
    • ALL
    • Hide

      1. Create sharded collection with shardkey as hashed _id.
      2. Fill with whatever
      3. Lookup one chunks borders
      4. Query like this for all documents in that chunk:

      db.collection.find(
      { "_id" :

      { "$gte" : -9219144072535768301, "$lt" : -9214747938866076750}

      }).hint(

      { "_id" : "hashed"}

      )

      Behavior in 2.4: Query to one shard and use of index there.
      Behavior in 2.6: Very slow table scan on all shards

      Show
      1. Create sharded collection with shardkey as hashed _id. 2. Fill with whatever 3. Lookup one chunks borders 4. Query like this for all documents in that chunk: db.collection.find( { "_id" : { "$gte" : -9219144072535768301, "$lt" : -9214747938866076750} }).hint( { "_id" : "hashed"} ) Behavior in 2.4: Query to one shard and use of index there. Behavior in 2.6: Very slow table scan on all shards

    Description

      It was possible in 2.4 to query a sharded collection by hashedkey with hashed borders like this:

      db.collection.find(
      { "_id" :

      { "$gte" : -9219144072535768301, "$lt" : -9214747938866076750}

      }).hint(

      { "_id" : "hashed"}

      )

      The range values are chunk borders.
      This query returns all documents from this chunk only asking one shard.
      Moving to MongoDB 2.6 this stopped working.

      An explain returns BtreeCursor but scannedObjects is indication a whole table scan on all shards.
      Additionally it shows wrong indexBounds:

      "_id" : [
      [

      { "$minElement" : 1 }

      ,

      { "$maxElement" : 1 }

      ]
      ]

      The same problem arises in mongoDB's own hadoop connector when using hashed sharded collections. (https://github.com/mongodb/mongo-hadoop)

      Attachments

        Activity

          People

            Unassigned Unassigned
            breitlauch Daniel Breitlauch
            Votes:
            3 Vote for this issue
            Watchers:
            10 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: