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

    • Type: Bug
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Fixed
    • Affects Version/s: 4.1.8
    • Fix Version/s: 4.0.9, 4.1.10
    • Component/s: None
    • Labels:
    • Backwards Compatibility:
      Fully Compatible
    • Operating System:
      ALL
    • Backport Requested:
      v4.0
    • Steps To Reproduce:
      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] ]}}})
    • Sprint:
      Query 2019-03-11, Query 2019-03-25
    • Linked BF Score:
      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

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

                Dates

                • Created:
                  Updated:
                  Resolved: