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

Fix invariant failure in SlotBasedStageBuilder::buildOr()

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 4.9.0
    • Affects Version/s: None
    • Component/s: Querying
    • Labels:
    • Fully Compatible
    • ALL
    • Hide

       

      > db.coll.insert(
       [{_id: 1, a: 8, b: 3, c: 4, d: 0},
       {_id: 2, a: 1, b: 5, c: 9, d: 1},
       {_id: 3, a: 6, b: 7, c: 2, d: 1},
       {_id: 4, a: 4, b: 8, c: 3, d: 0},
       {_id: 5, a: 9, b: 1, c: 5, d: 1},
       {_id: 6, a: 2, b: 6, c: 7, d: 0},
       {_id: 7, a: 3, b: 4, c: 8, d: 0},
       {_id: 8, a: 5, b: 9, c: 1, d: 0},
       {_id: 9, a: 7, b: 2, c: 6, d: 1},
       {_id: 10, b: 3, c: 4, d: 0},
       {_id: 11, a: 8, b: 3, d: 0},
       {_id: 12, a: 9, c: 5, d: 1},
       {_id: 13, a: 9, b: 1, d: 1}]);
      > db.coll.createIndex({a: 1});
      > db.coll.createIndex({b: 1});
      > db.adminCommand({setParameter:1, internalQueryEnableSlotBasedExecutionEngine:true});
      > db.coll.find({$or: [{a: {$gt: 6}}, {b: {$lt: 4}}]})
      

       

      Show
        > db.coll.insert( [{_id: 1, a: 8, b: 3, c: 4, d: 0}, {_id: 2, a: 1, b: 5, c: 9, d: 1}, {_id: 3, a: 6, b: 7, c: 2, d: 1}, {_id: 4, a: 4, b: 8, c: 3, d: 0}, {_id: 5, a: 9, b: 1, c: 5, d: 1}, {_id: 6, a: 2, b: 6, c: 7, d: 0}, {_id: 7, a: 3, b: 4, c: 8, d: 0}, {_id: 8, a: 5, b: 9, c: 1, d: 0}, {_id: 9, a: 7, b: 2, c: 6, d: 1}, {_id: 10, b: 3, c: 4, d: 0}, {_id: 11, a: 8, b: 3, d: 0}, {_id: 12, a: 9, c: 5, d: 1}, {_id: 13, a: 9, b: 1, d: 1}]); > db.coll.createIndex({a: 1}); > db.coll.createIndex({b: 1}); > db.adminCommand({setParameter:1, internalQueryEnableSlotBasedExecutionEngine:true}); > db.coll.find({$or: [{a: {$gt: 6}}, {b: {$lt: 4}}]})  
    • Query 2020-09-07, Query 2020-09-21, Query 2020-10-05, Query 2020-10-19, Query 2020-11-02, Query 2020-11-16

      When I was testing out using the $or operator in the first parameter to find() (with SBE mode enabled), I found a case where an invariant in SlotBasedStageBuilder::buildOr() fails.

      The invariant that fails is "invariant(_data.resultSlot);" around line 350 of "src/mongo/db/query/sbe_stage_builder.cpp".

      The goal of this task is to investigate why the invariant is failing, diagnose the underlying problem, and implement a fix.

      When this issue is fixed, the "jstests/core/and_or_nested.js" should be updated to verify all of its queries work when there is both an index on field 'a' and an index on field 'b'.

            Assignee:
            andrew.paroski@mongodb.com Drew Paroski
            Reporter:
            andrew.paroski@mongodb.com Drew Paroski
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: