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

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 4.0.9, 4.1.10
    • Affects Version/s: 4.1.8
    • Component/s: 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

      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 

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

              Created:
              Updated:
              Resolved: