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

    • Type: Icon: Bug Bug
    • Resolution: Unresolved
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • Query Execution
    • ALL
    • 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: