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

Time-series $match on dates before 1970 can miss documents

    • Query Integration
    • Fully Compatible
    • ALL
    • v8.0, v7.0, v6.0, v5.0

      The following repro demonstrates the issue. The explain shows an EOF plan being generated. Spoke to gil.alon@mongodb.com about this and we believe the _id predicates or other additional bucket-level predicates that are generated conflict in a way where the optimizer believes no document can be returned.

      const tsColl = db.ts;
      const coll = db.c;
      tsColl.drop();
      coll.drop();
      
      assert.commandWorked(db.createCollection(tsColl.getName(), {
      	timeseries: {timeField: 't', metaField: 'm'},
      }));
      
      const docs = [
      	{
      		"t" : ISODate("1969-12-31T23:59:59.415Z"),
      		"_id" : 0
      	}
      ]
      assert.commandWorked(coll.insert(docs))
      assert.commandWorked(tsColl.insert(docs))
      
      query = [
      	{
      		"$match" : {
      			"t" :  ISODate("1969-12-31T23:59:59.415Z")
      		}
      	}
      ]
      
      const expected = coll.aggregate(query).toArray();
      const actual = tsColl.aggregate(query).toArray();
      jsTestLog(expected)
      // Finds the document
      jsTestLog(actual)
      // Empty results
      
      const exp = tsColl.explain().aggregate(query);
      jsTestLog(exp)
      // EOF plan
      

            Assignee:
            gil.alon@mongodb.com Gil Alon
            Reporter:
            matt.boros@mongodb.com Matt Boros
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: