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

non-top-level indexable $not triggers query planning bug

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Fixed
    • Affects Version/s: 2.6.0
    • Fix Version/s: 2.6.2, 2.7.0
    • Component/s: Querying
    • Labels:
    • Operating System:
      ALL
    • Backport Completed:
    • Steps To Reproduce:
      Hide

      > db.posts.find({"$and":[{"$or":[{"is_draft":false},{"creator_id":ObjectId("5258540936a42b1240000030")}]},{"$or":[{"state":3,"is_draft":false},{"published_date":{"$ne":null}}]},{"newsroom_id":{"$in":[ObjectId("4e962c5bcbcf1f0001000373")]}}]})
       
      error: { "$err" : "assertion src/mongo/db/query/plan_enumerator.cpp:1040" }

      Show
      > db.posts.find({"$and":[{"$or":[{"is_draft":false},{"creator_id":ObjectId("5258540936a42b1240000030")}]},{"$or":[{"state":3,"is_draft":false},{"published_date":{"$ne":null}}]},{"newsroom_id":{"$in":[ObjectId("4e962c5bcbcf1f0001000373")]}}]})   error: { "$err" : "assertion src/mongo/db/query/plan_enumerator.cpp:1040" }

      Description

      Issue Status as of May 14, 2014

      ISSUE SUMMARY
      A query with a non-top-level $not or $ne operator using an index triggers a bug in the query planning system and fails with an assertion error.

      Example:

      db.coll.find( {'$or': [ {'state': 1, 'is_draft': 1}, 
                              {'published_date': {'$ne': 1} } ] } )

      This query has a negation underneath an $or parent node. If each of the fields is indexed, this query would trigger the bug.

      USER IMPACT
      Queries matching the above condition fail with an assertion.

      WORKAROUNDS
      Rewrite the query to avoid non-top-level negation on indexed fields if possible.

      AFFECTED VERSIONS
      Versions 2.6.0 and 2.6.1 are affected by this issue.

      FIX VERSION
      The fix is included in the 2.6.2 production release.

      RESOLUTION DETAILS
      A bug in creating the memoized data structure used to enumerate the space of query plans is now fixed.

      Original description

      A query that used to work on 2.2 is now failing when upgrading to 2.6.

        Attachments

          Activity

            People

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

              Dates

              • Created:
                Updated:
                Resolved: