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

Negation of $in with embedded array can incorrectly plan from the cache, triggering invariant

    XMLWordPrintable

Details

    • Bug
    • Status: Closed
    • Major - P3
    • Resolution: Fixed
    • 4.1.8
    • 4.0.9, 4.1.10
    • None
    • Fully Compatible
    • ALL
    • v4.0
    • Hide

      db.test.drop()
       
      db.test.createIndex({"obj": 1})
      db.test.createIndex({"obj": 1, "abc": 1})
       
      db.test.find({'obj': {$ne: 'def'}})
      db.test.find({'obj': {$ne: 'def'}})
      db.test.find({'obj': {$not: {$in: [ [1] ]}}})
      

      Show
      db.test.drop() db.test.createIndex({ "obj" : 1}) db.test.createIndex({ "obj" : 1, "abc" : 1}) db.test.find({ 'obj' : {$ne: 'def' }}) db.test.find({ 'obj' : {$ne: 'def' }}) db.test.find({ 'obj' : {$not: {$ in : [ [1] ]}}})
    • Query 2019-03-11, Query 2019-03-25
    • 67

    Description

      This issue started with the commit for SERVER-38949. Under that ticket we ban index use for negation of equality to array. It is still possible however to generate a plan cache entry for a negation of equality to non-array, and to then use the cached entry for negation of equality to array.

      To address we will likely want to modify the plan cache to discriminate between distinguish between array and non-array values for {$not: {$in: ...}} entries.

      The invariant triggered is:

      Invariant failure *tightnessOut == IndexBoundsBuilder::EXACT src/mongo/db/query/index_bounds_builder.cpp 429 

      Attachments

        Issue Links

          Activity

            People

              ian.boros@mongodb.com Ian Boros
              james.wahlin@mongodb.com James Wahlin
              Votes:
              0 Vote for this issue
              Watchers:
              8 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: