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

Hinting an incompatible partial index can return incomplete results

    XMLWordPrintable

Details

    • Bug
    • Status: Backlog
    • Major - P3
    • Resolution: Unresolved
    • 3.2.4, 3.3.8
    • None
    • None
    • ALL
    • Hide

      > c = db.col
      test.col
      > c.drop()
      false
      > c.insert({x:100})
      WriteResult({ "nInserted" : 1 })
      > c.createIndex({x:1},{partialFilterExpression:{y:{$exists:true}}})
      {
      	"createdCollectionAutomatically" : false,
      	"numIndexesBefore" : 1,
      	"numIndexesAfter" : 2,
      	"ok" : 1
      }
      > 
      > 
      > c.find({x:100})
      { "_id" : ObjectId("57ee96b1d2002c23be038661"), "x" : 100 }
      >
      > c.find({x:100}).hint({x:1})
      > 
      

      Show
      > c = db.col test.col > c.drop() false > c.insert({x:100}) WriteResult({ "nInserted" : 1 }) > c.createIndex({x:1},{partialFilterExpression:{y:{$exists:true}}}) { "createdCollectionAutomatically" : false, "numIndexesBefore" : 1, "numIndexesAfter" : 2, "ok" : 1 } > > > c.find({x:100}) { "_id" : ObjectId("57ee96b1d2002c23be038661"), "x" : 100 } > > c.find({x:100}).hint({x:1}) >

    Description

      The database currently allows for partial indexes to be hinted regardless of the filters applied to the query. When these filters do not align with the partialFilterExpression for an index, there may be documents that match the query but are not included in the index. Forcing index usage via a hint in such a scenario will lead to the database returning incomplete results (a silent logical failure).

      Returning an error is probably the most correct thing to do. Alternatively, the hint could be rejected and the standard plan generation process could be observed.

      Attachments

        Issue Links

          Activity

            People

              backlog-query-execution Backlog - Query Execution
              christopher.harris@mongodb.com Christopher Harris
              Votes:
              1 Vote for this issue
              Watchers:
              12 Start watching this issue

              Dates

                Created:
                Updated: