ExportXMLWordPrintableJSON

    • Query Execution
    • Fully Compatible
    • ALL
    • Hide

       

      
      /**
       * JOO tassert 4946301 "undefined slot accessor": a nested loop join whose left (outer) side is a
       * foreign node with a sub-pipeline $project that renames the field a later join reads.
       *
       * Plan that fails (b is the sub-pipeline node): HJ( NLJ(PROJECTION(COLLSCAN b), COLLSCAN a), c ).
       * The join method is forced here; the same plan is chosen naturally with e.g. 2/1/2 documents.
       */
      const conn = MongoRunner.runMongod({
          setParameter: {
              internalEnableJoinOptimization: true,
              featureFlagPathArrayness: true,
              featureFlagCostBasedRanker: true,
              internalEnableJoinPlanCache: false,
              internalJoinMethod: "NLJ",
          },
      });
      const db = conn.getDB("test");
      try {
          assert.commandWorked(db.a.insertMany([{_id: 1, x: 1}, {_id: 2, x: 2}]));
          assert.commandWorked(db.b.insertMany([{_id: 1, y: 1, w: 5}, {_id: 2, y: 2, w: 6}]));
          assert.commandWorked(db.c.insertMany([{_id: 1, z: 5}, {_id: 2, z: 1}]));
          assert.commandWorked(db.a.createIndex({x: 1}));
          assert.commandWorked(db.b.createIndex({y: 1}));
          assert.commandWorked(db.b.createIndex({w: 1}));
          assert.commandWorked(db.c.createIndex({z: 1}));
      
          const pipeline = [
              {$lookup: {from: "b", localField: "x", foreignField: "y", pipeline: [{$project: {y: "$w", w: "$y"}}], as: "b"}},
              {$unwind: "$b"},
              {$lookup: {from: "c", localField: "b.y", foreignField: "z", as: "c"}},
              {$unwind: "$c"},
          ];
          assert.commandWorked(db.adminCommand({setParameter: 1, internalEnableJoinOptimization: false}));
          const expected = db.a.aggregate(pipeline).toArray();
          assert.eq(expected.length, 1, tojson(expected));
          assert.commandWorked(db.adminCommand({setParameter: 1, internalEnableJoinOptimization: true}));
          const res = db.runCommand({aggregate: "a", pipeline: pipeline, cursor: {}});
          assert.commandWorked(res);
          assert.sameMembers(res.cursor.firstBatch, expected);
      } finally {
          MongoRunner.stopMongod(conn);
      }
      
      
      

       

      Show
        /** * JOO tassert 4946301 "undefined slot accessor" : a nested loop join whose left (outer) side is a * foreign node with a sub-pipeline $project that renames the field a later join reads. * * Plan that fails (b is the sub-pipeline node): HJ( NLJ(PROJECTION(COLLSCAN b), COLLSCAN a), c ). * The join method is forced here; the same plan is chosen naturally with e.g. 2/1/2 documents. */ const conn = MongoRunner.runMongod({ setParameter: { internalEnableJoinOptimization: true , featureFlagPathArrayness: true , featureFlagCostBasedRanker: true , internalEnableJoinPlanCache: false , internalJoinMethod: "NLJ" , }, }); const db = conn.getDB( "test" ); try { assert.commandWorked(db.a.insertMany([{_id: 1, x: 1}, {_id: 2, x: 2}])); assert.commandWorked(db.b.insertMany([{_id: 1, y: 1, w: 5}, {_id: 2, y: 2, w: 6}])); assert.commandWorked(db.c.insertMany([{_id: 1, z: 5}, {_id: 2, z: 1}])); assert.commandWorked(db.a.createIndex({x: 1})); assert.commandWorked(db.b.createIndex({y: 1})); assert.commandWorked(db.b.createIndex({w: 1})); assert.commandWorked(db.c.createIndex({z: 1})); const pipeline = [ {$lookup: {from: "b" , localField: "x" , foreignField: "y" , pipeline: [{$project: {y: "$w" , w: "$y" }}], as: "b" }}, {$unwind: "$b" }, {$lookup: {from: "c" , localField: "b.y" , foreignField: "z" , as: "c" }}, {$unwind: "$c" }, ]; assert.commandWorked(db.adminCommand({setParameter: 1, internalEnableJoinOptimization: false })); const expected = db.a.aggregate(pipeline).toArray(); assert.eq(expected.length, 1, tojson(expected)); assert.commandWorked(db.adminCommand({setParameter: 1, internalEnableJoinOptimization: true })); const res = db.runCommand({aggregate: "a" , pipeline: pipeline, cursor: {}}); assert.commandWorked(res); assert.sameMembers(res.cursor.firstBatch, expected); } finally { MongoRunner.stopMongod(conn); }  
    • QE 2026-10-26
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      Plan HJ(NLJ(PROJECTION_DEFAULT(COLLSCAN b), COLLSCAN a), COLLSCAN c) where b's sub-pipeline $project renames the field the second join reads (b.y). The NLJ stage builder in gen_lookup.cpp does not export the renamed slot from the outer side, and the plan fails at prepare time.

       

      assert: command failed: { "errmsg" : "undefined slot accessor:4", "code" : 4946301, "codeName" : "Location4946301" }
      Tripwire assertion: src/mongo/db/exec/sbe/expressions/runtime_environment.cpp:99 RuntimeEnvironment::getAccessor
      

       

            Assignee:
            Alberto Massari
            Reporter:
            Max Verbinnen
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: