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

Covering hashed index on fields that share path prefix can return incorrect results in SBE

    • Type: Icon: Bug Bug
    • Resolution: Unresolved
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 6.2.1, 7.0.8, 8.0.4
    • Component/s: None
    • Query Execution
    • ALL
    • Hide
      const query =
          [
              {$match: {a: 1}},
              {
                  $group: {
                      '_id': '$m.m1',
                  }
              }
          ]
      
      const index = {
      	a: 1,
      	m: 'hashed',
      	'm.m1': 1
      }
      
      assert(db.c.drop())
      assert.commandWorked(db.c.insert({_id: 1, a: 1, m: {m1: 2}}))
      jsTestLog(db.c.aggregate(query).toArray())
      // [ { "_id" : 2 } ]
      
      assert.commandWorked(db.c.createIndex(index))
      jsTestLog(db.c.aggregate(query).toArray())
      // [ { "_id" : null } ]
      
      jsTestLog(db.c.explain().aggregate(query))
      // Hashed index covers, query uses SBE
      
      Show
      const query = [ {$match: {a: 1}}, { $group: { '_id' : '$m.m1' , } } ] const index = { a: 1, m: 'hashed' , 'm.m1' : 1 } assert (db.c.drop()) assert .commandWorked(db.c.insert({_id: 1, a: 1, m: {m1: 2}})) jsTestLog(db.c.aggregate(query).toArray()) // [ { "_id" : 2 } ] assert .commandWorked(db.c.createIndex(index)) jsTestLog(db.c.aggregate(query).toArray()) // [ { "_id" : null } ] jsTestLog(db.c.explain().aggregate(query)) // Hashed index covers, query uses SBE
    • QE 2025-02-03, QE 2025-02-17, QE 2025-03-03

      (Repro provided) Running a query that doesn't need a fetch on a hashed index that satisfies a predicate and covers two similar fields can return incorrect results.

      I was going to reopen SERVER-91757 since it's very similar, but I don't have permissions. However I now think it has a different root cause since this only repros with SBE and the SERVER-91757 fix only touched classic execution code.

            Assignee:
            evan.bergeron@mongodb.com Evan Bergeron
            Reporter:
            matt.boros@mongodb.com Matt Boros
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated: