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

sharded $searchMeta queries in a $lookup and $unionWith fail by hitting an unreachable_tassert

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Critical - P2 Critical - P2
    • 8.1.0-rc0, 8.0.4
    • Affects Version/s: None
    • Component/s: None
    • None
    • Query Integration
    • Fully Compatible
    • ALL
    • v8.0
    • Hide
      const coll = db[jsTestName()];
      coll.drop();
      const numDocs = 10000;
      let docs = [];
      
      let genres = [
          "Drama",
          "Comedy",
          "Romance",
      ];
      for (let i = 0; i < numDocs; i++) {
          const genre = genres[i % 10];
          docs.push(\{_id: i, index: i % 1000, element: "fire", genre: genre});
      }
      assert.commandWorked(coll.insertMany(docs));
      
      coll.createSearchIndex({
          name: "facet-index",
          definition: {
              "mappings": {
                  "dynamic": false,
                  "fields": {
                      "index": \{"type": "number"},
                      "genre": \{"type": "stringFacet"}
                  }
              }
          }
      });
      
      const countQuery = {
          "$searchMeta": {
              "index": "facet-index",
              "range": \{"path": "index", "gte": 100, "lt": 9000},
              "count": \{"type": "total"}
          }
      };
      
      
      // Another collection for $lookup and $unionWith queries.
      const collBase = db.base;
      collBase.drop();
      assert.commandWorked(collBase.insert(\{"_id": 100, "localField": "cakes", "weird": false}));
      
      
          //Test $searchMeta with $lookup.
          let result = collBase.aggregate([\{$match: {_id: 100}},
              {
                  $lookup: {
                      from: coll.getName(),
                      pipeline: [
                          countQuery],
                      as: "meta_facet"
                  }
              }]).toArray();
      
       //Test $searchMeta with $unionWith.
              let result = collBase.aggregate(
                  [{
                      $unionWith: {
                          coll: coll.getName(),
                          pipeline: [
                              countQuery,
                          ]
                      }
                  }]).toArray();
      
      Show
      const coll = db[jsTestName()]; coll.drop(); const numDocs = 10000; let docs = []; let genres = [     "Drama" ,     "Comedy" ,     "Romance" , ]; for (let i = 0; i < numDocs; i++) {     const genre = genres[i % 10];     docs.push(\{_id: i, index: i % 1000, element: "fire" , genre: genre}); } assert .commandWorked(coll.insertMany(docs)); coll.createSearchIndex({     name: "facet-index" ,     definition: {         "mappings" : {             "dynamic" : false ,             "fields" : {                 "index" : \{ "type" : "number" },                 "genre" : \{ "type" : "stringFacet" }             }         }     } }); const countQuery = {     "$searchMeta" : {         "index" : "facet-index" ,         "range" : \{ "path" : "index" , "gte" : 100, "lt" : 9000},         "count" : \{ "type" : "total" }     } }; // Another collection for $lookup and $unionWith queries. const collBase = db.base; collBase.drop(); assert .commandWorked(collBase.insert(\{ "_id" : 100, "localField" : "cakes" , "weird" : false }));     //Test $searchMeta with $lookup.     let result = collBase.aggregate([\{$match: {_id: 100}},         {             $lookup: {                 from: coll.getName(),                 pipeline: [                     countQuery],                 as: "meta_facet"             }         }]).toArray(); //Test $searchMeta with $unionWith. let result = collBase.aggregate( [{ $unionWith: { coll: coll.getName(), pipeline: [ countQuery, ] } }]).toArray();

      Run the attached test with the search_end_to_end_sharded_cluster suite to replicate.

      Running the test hits this unreachable_tassert (https://github.com/10gen/mongo/blob/277db2300a7bf3d576e8348167fbdcdae8ee2fae/src/mongo/db/pipeline/search/document_source_internal_search_mongot_remote.h#L94). 

            Assignee:
            charlie.swanson@mongodb.com Charlie Swanson
            Reporter:
            erin.zhu@mongodb.com Erin Zhu
            Votes:
            0 Vote for this issue
            Watchers:
            15 Start watching this issue

              Created:
              Updated:
              Resolved: