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

CBR asserts on $meta projection of sortKey

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 8.1.0-rc0
    • Affects Version/s: None
    • Component/s: None
    • None
    • Query Optimization
    • Fully Compatible
    • ALL
    • QO 2025-02-03

      > db.adminCommand({setParameter:1, planRankerMode: "heuristicCE"})
      > db.c.find({}, {a: {$meta: 'sortKey'}}).sort({a: 1}) 
      MongoServerError: Encountered 34 stage in CardinalityEstimator which should be unreachable

      The plan for this query looks like

      winningPlan: {
            isCached: false,
            stage: 'PROJECTION_DEFAULT',
            transformBy: { a: { '$meta': 'sortKey' } },
            inputStage: {
              stage: 'SORT_KEY_GENERATOR',
              inputStage: {
                stage: 'FETCH',
                inputStage: {
                  stage: 'IXSCAN',
                  keyPattern: { a: 1 },
                  indexName: 'a_1',
                  isMultiKey: true,
                  multiKeyPaths: { a: [ 'a' ] },
                  isUnique: false,
                  isSparse: false,
                  isPartial: false,
                  indexVersion: 2,
                  direction: 'forward',
                  indexBounds: { a: [ '[MinKey, MaxKey]' ] }
                }
              }
            }
          }, 

      CBR needs to fallback to multiplanning for plans which contain a  SORT_KEY_GENERATOR stage.

            Assignee:
            ben.shteinfeld@mongodb.com Ben Shteinfeld
            Reporter:
            ben.shteinfeld@mongodb.com Ben Shteinfeld
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: