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

CollectionsInfo map doesn't contain foreign collection when $lookup is a sub-pipeline

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

      Start mongod with lookup pushdown feature flag on,

      ./build/opt/install/bin/mongod --setParameter featureFlagSBELookupPushdown=true

      Run these commands in a shell

      > assert.commandWorked(db.createCollection("baseColl"));
      > assert.commandWorked(db.createCollection("unionColl"));
      > assert.commandWorked(db.createCollection("lookupColl"));
      > db.baseColl.explain().aggregate([{$unionWith: {coll: "unionColl", pipeline: [{$lookup: {from: "lookupColl", localField: "_id", foreignField: "_id", as: "results"}}]}}])

      The error we get is:

      uncaught exception: Error: command failed: {uncaught exception: Error: command failed: { "ok" : 0, "errmsg" : "Expected collection info, but found none; target collection: test.lookupColl", "code" : 5842600, "codeName" : "Location5842600"} with original command request: { "aggregate" : "baseColl", "pipeline" : [ { "$unionWith" : { "coll" : "unionColl", "pipeline" : [ { "$lookup" : { "from" : "lookupColl", "localField" : "_id", "foreignField" : "_id", "as" : "results" } } ] } } ], "explain" : true, "cursor" : { }, "lsid" : { "id" : UUID("e48870c4-edc9-4044-9b0d-579a8a5fffd4") }}
      

       

      Show
      Start mongod with lookup pushdown feature flag on, ./build/opt/install/bin/mongod --setParameter featureFlagSBELookupPushdown=true Run these commands in a shell > assert .commandWorked(db.createCollection( "baseColl" )); > assert .commandWorked(db.createCollection( "unionColl" )); > assert .commandWorked(db.createCollection( "lookupColl" )); > db.baseColl.explain().aggregate([{$unionWith: {coll: "unionColl" , pipeline: [{$lookup: {from: "lookupColl" , localField: "_id" , foreignField: "_id" , as: "results" }}]}}]) The error we get is: uncaught exception: Error: command failed: {uncaught exception: Error: command failed: { "ok" : 0, "errmsg" : "Expected collection info, but found none; target collection: test.lookupColl", "code" : 5842600, "codeName" : "Location5842600"} with original command request: { "aggregate" : "baseColl", "pipeline" : [ { "$unionWith" : { "coll" : "unionColl", "pipeline" : [ { "$lookup" : { "from" : "lookupColl", "localField" : "_id", "foreignField" : "_id", "as" : "results" } } ] } } ], "explain" : true, "cursor" : { }, "lsid" : { "id" : UUID("e48870c4-edc9-4044-9b0d-579a8a5fffd4") }}  
    • QE 2022-04-04, QE 2022-03-21

      We are observing a tassert tripping when deciding on the lookup algorithm strategy when $lookup is a sub-pipeline of $unionWith. If I run the repro steps below and dump the collectionsInfo map in QueryPlannerAnalysis::determineLookupStrategy all that the map contains is

      *** Collection info:
      k = test.unionColl
      *** Collection info done
      

            Assignee:
            mihai.andrei@mongodb.com Mihai Andrei
            Reporter:
            eric.cox@mongodb.com Eric Cox (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: