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

$lookup on time-series collection using bounded sorter can lead to incorrect uassert

    • Type: Icon: Bug Bug
    • Resolution: Unresolved
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • Query Integration
    • ALL
    • Hide
      foreignCollDocs = [
          {
              "_id" : 0,
              "t" : ISODate("1969-12-31T23:59:59Z"),
              "m" : 0
          },
          {
              "_id" : 1,
              "t" : ISODate("1970-01-01T00:59:00Z"),
              "m" : 1
          }
      ];
      
      const localColl = db.local_coll;
      const foreignColl = db.foreign_coll;
      assert(localColl.drop())
      assert(foreignColl.drop())
      // localColl is a regular collection, foreignColl is a time-series collection
      assert.commandWorked(localColl.insert([{a: 1}]))
      assert.commandWorked(db.createCollection(foreignColl.getName(), {
          timeseries: {timeField: 't', metaField: 'm'},
      }));
      assert.commandWorked(foreignColl.insert(foreignCollDocs))
      
      
      jsTestLog(localColl.aggregate([{$lookup: {from: 'foreign_coll', pipeline: [{$sort: {t: 1}}], as: 'result'}}]).toArray())
      // BoundedSorter input is too out-of-order: with bound 1970-01-01T00:59:00.000+00:00, did not expect input Date(-1000)
      
      Show
      foreignCollDocs = [ { "_id" : 0, "t" : ISODate( "1969-12-31T23:59:59Z" ), "m" : 0 }, { "_id" : 1, "t" : ISODate( "1970-01-01T00:59:00Z" ), "m" : 1 } ]; const localColl = db.local_coll; const foreignColl = db.foreign_coll; assert (localColl.drop()) assert (foreignColl.drop()) // localColl is a regular collection, foreignColl is a time-series collection assert .commandWorked(localColl.insert([{a: 1}])) assert .commandWorked(db.createCollection(foreignColl.getName(), { timeseries: {timeField: 't' , metaField: 'm' }, })); assert .commandWorked(foreignColl.insert(foreignCollDocs)) jsTestLog(localColl.aggregate([{$lookup: {from: 'foreign_coll' , pipeline: [{$sort: {t: 1}}], as: 'result' }}]).toArray()) // BoundedSorter input is too out-of-order: with bound 1970-01-01T00:59:00.000+00:00, did not expect input Date(-1000)
    • None
    • 3
    • TBD
    • None
    • None
    • None
    • None
    • None
    • None

      The following repro shows that when $lookup is performed on a time-series collection, and the inner pipeline has a sort on time (which uses the bounded sorter), we can throw a uassert when the query is valid.

            Assignee:
            Unassigned Unassigned
            Reporter:
            matt.boros@mongodb.com Matt Boros
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: