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

$group on time-series collections can produce rounded results due to bucket control rounding

    • Query Execution
    • Fully Compatible
    • ALL
    • v8.0
    • 200

      Repro:

      docs = [
      	{
      		"t" : ISODate("1969-12-31T23:59:59.999Z"),
      		"m" : {
      	
      		},
      		"_id" : 0
      	}
      ]
      
      const coll = db.c;
      assert.commandWorked(db.createCollection(coll.getName(), {
      timeseries: {timeField: 't', metaField: 'm'},
      }));
      
      assert.commandWorked(coll.insert(docs))
      
      jsTestLog(db.system.buckets.c.find().toArray())
      
      query = [
      	{
      		"$group" : {
      			"_id" : "$t",
      			"m" : {
      				"$max" : "$t"
      			}
      		}
      	}
      ]
      jsTestLog(coll.aggregate(query).toArray())
      // "m" contains the wrong result (rounded)
      

      The issue appears to be from the "control.max" field for time being rounded up to a different date, and then being used in computing the max in the $group.

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

              Created:
              Updated:
              Resolved: