• Type: Bug
    • Resolution: Unresolved
    • Priority: Major - P3
    • None
    • Affects Version/s: 9.0.8
    • Component/s: None
    • None
    • Query Execution
    • ALL
    • Hide

      Affects versions: 9.0.8 and master (2f8d82a7, 2026-11-18). Default server parameters. Standalone mongod; Ubuntu 24.04 x86_64 and macOS arm64 give the same output.

      Repro

      db = db.getSiblingDB("test");
      db.local.drop();
      db.foreign.drop();
      db.local.insertOne({_id: 1, a: [2.5, 2]});
      db.foreign.insertOne({_id: 2, a: 2});
      db.foreign.createIndex({a: "hashed"});
      const pipeline = [{$lookup: {from: "foreign", localField: "a", foreignField: "a", as: "j"}}];
      print("default:            " + EJSON.stringify(db.local.aggregate(pipeline).toArray()));
      db.adminCommand({setParameter: 1, internalQueryFrameworkControl: "forceClassicEngine"});
      print("forceClassicEngine: " + EJSON.stringify(db.local.aggregate(pipeline).toArray()));
      

      Output (9.0.8)

      default:            [{"_id":1,"a":[2.5,2],"j":[{"_id":2,"a":2},{"_id":2,"a":2}]}]
      forceClassicEngine: [{"_id":1,"a":[2.5,2],"j":[{"_id":2,"a":2}]}]
      

      Master 2f8d82a7 prints the same lines.

      Show
      Affects versions: 9.0.8 and master (2f8d82a7, 2026-11-18). Default server parameters. Standalone mongod; Ubuntu 24.04 x86_64 and macOS arm64 give the same output. Repro db = db.getSiblingDB( "test" ); db.local.drop(); db.foreign.drop(); db.local.insertOne({_id: 1, a: [2.5, 2]}); db.foreign.insertOne({_id: 2, a: 2}); db.foreign.createIndex({a: "hashed" }); const pipeline = [{$lookup: {from: "foreign" , localField: "a" , foreignField: "a" , as: "j" }}]; print( " default :            " + EJSON.stringify(db.local.aggregate(pipeline).toArray())); db.adminCommand({setParameter: 1, internalQueryFrameworkControl: "forceClassicEngine" }); print( "forceClassicEngine: " + EJSON.stringify(db.local.aggregate(pipeline).toArray())); Output (9.0.8) default:            [{"_id":1,"a":[2.5,2],"j":[{"_id":2,"a":2},{"_id":2,"a":2}]}] forceClassicEngine: [{"_id":1,"a":[2.5,2],"j":[{"_id":2,"a":2}]}] Master 2f8d82a7 prints the same lines.
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      With a hashed index on the foreignField, SBE's $lookup returns the same foreign document once per local array value that hashes to the same key. Here local a: [2.5, 2] against foreign {_id: 2, a: 2} gives j with {_id: 2} twice; the classic engine returns it once.

       

      Found with Ephyra, a property-based testing tool I'm developing; this report was drafted with an LLM from the test output, and I reviewed it and reran the repro on 9.0.8 and master.

            Assignee:
            Unassigned
            Reporter:
            Alperen Keleş (EXT)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: