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

shard selection code ignores bound inclusivity

    • Type: Icon: Improvement Improvement
    • Resolution: Duplicate
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: Sharding
    • Labels:
      None

              void getShardsForRange(set<Shard>& shards, const BSONObj& min, const BSONObj& max, bool fullKeyReq = true) const; // [min, max)
      

      The [min, max) comment is incorrect here, both min and max are treated as inclusive bounds. That means for a query like {a:{$lt:5}} a chunk [

      {a:5}

      ,

      {a:6}

      ) will be considered to potentially contain matches even though it cannot contain matches. Similarly, it looks like the datasize command calls this function with the expectation that max is treated as an exclusive bound, even though it is not.

      There's no functional error here, just a possibility of sending the operation to a shard unnecessarily. And also, currently there are cases where an inclusive upper bound must be supported - so to optimize we'd need to support both inclusive and exclusive bounds.

      Descriptive test written, push pending bb code freeze.

            Assignee:
            Unassigned Unassigned
            Reporter:
            aaron Aaron Staple
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: