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

Hinting an incompatible partial index can return incomplete results

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Open
    • Priority: Major - P3
    • Resolution: Unresolved
    • Affects Version/s: 3.2.4, 3.3.8
    • Fix Version/s: Backlog
    • Component/s: None
    • Operating System:
      ALL
    • Steps To Reproduce:
      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}) >
    • Case:

      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

              Assignee:
              backlog-query-execution Backlog - Query Execution
              Reporter:
              christopher.harris Christopher Harris
              Participants:
              Votes:
              1 Vote for this issue
              Watchers:
              12 Start watching this issue

                Dates

                Created:
                Updated: