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

Time-series bucket can be created that violates max time-span

    XMLWordPrintable

Details

    • Bug
    • Status: Closed
    • Major - P3
    • Resolution: Fixed
    • 6.0.0-rc7
    • 5.0.10, 6.0.0-rc10, 6.1.0-rc0
    • None
    • None
    • Fully Compatible
    • ALL
    • v6.0, v5.0
    • Hide

      > db.weather.drop()
      false
      > db.createCollection(     "weather",     {        timeseries: {           timeField: "timestamp",           metaField: "metadata",           granularity: "hours"        }     } )
      { "ok" : 1 }
      > db.weather.insertMany( [    {       "metadata": { "sensorId": 5578, "type": "temperature" },       "timestamp": ISODate("2105-06-24T06:28:16Z"),       "temp": 12    }])
      {
      	"acknowledged" : true,
      	"insertedIds" : [
      		ObjectId("628d0c27231ed7a35f109c7f")
      	]
      }
      > db.weather.insertMany( [    {       "metadata": { "sensorId": 5578, "type": "temperature" },       "timestamp": ISODate("1969-05-18T00:00:00.000Z"),       "temp": 12    }])
      {
      	"acknowledged" : true,
      	"insertedIds" : [
      		ObjectId("628d0c31231ed7a35f109c81")
      	]
      }
      > db.system.buckets.weather.find()
      { "_id" : ObjectId("fed30f004d9e3cfa51f88755"), "control" : { "version" : 1, "min" : { "_id" : ObjectId("628d0c27231ed7a35f109c7f"), "timestamp" : ISODate("1969-05-18T00:00:00Z"), "temp" : 12 }, "max" : { "_id" : ObjectId("628d0c31231ed7a35f109c81"), "timestamp" : ISODate("2105-06-24T06:28:16Z"), "temp" : 12 } }, "meta" : { "sensorId" : 5578, "type" : "temperature" }, "data" : { "_id" : { "0" : ObjectId("628d0c27231ed7a35f109c7f"), "1" : ObjectId("628d0c31231ed7a35f109c81") }, "timestamp" : { "0" : ISODate("2105-06-24T06:28:16Z"), "1" : ISODate("1969-05-18T00:00:00Z") }, "temp" : { "0" : 12, "1" : 12 } } }
      > 
      

      Show
      > db.weather.drop() false > db.createCollection( "weather", { timeseries: { timeField: "timestamp", metaField: "metadata", granularity: "hours" } } ) { "ok" : 1 } > db.weather.insertMany( [ { "metadata": { "sensorId": 5578, "type": "temperature" }, "timestamp": ISODate("2105-06-24T06:28:16Z"), "temp": 12 }]) { "acknowledged" : true, "insertedIds" : [ ObjectId("628d0c27231ed7a35f109c7f") ] } > db.weather.insertMany( [ { "metadata": { "sensorId": 5578, "type": "temperature" }, "timestamp": ISODate("1969-05-18T00:00:00.000Z"), "temp": 12 }]) { "acknowledged" : true, "insertedIds" : [ ObjectId("628d0c31231ed7a35f109c81") ] } > db.system.buckets.weather.find() { "_id" : ObjectId("fed30f004d9e3cfa51f88755"), "control" : { "version" : 1, "min" : { "_id" : ObjectId("628d0c27231ed7a35f109c7f"), "timestamp" : ISODate("1969-05-18T00:00:00Z"), "temp" : 12 }, "max" : { "_id" : ObjectId("628d0c31231ed7a35f109c81"), "timestamp" : ISODate("2105-06-24T06:28:16Z"), "temp" : 12 } }, "meta" : { "sensorId" : 5578, "type" : "temperature" }, "data" : { "_id" : { "0" : ObjectId("628d0c27231ed7a35f109c7f"), "1" : ObjectId("628d0c31231ed7a35f109c81") }, "timestamp" : { "0" : ISODate("2105-06-24T06:28:16Z"), "1" : ISODate("1969-05-18T00:00:00Z") }, "temp" : { "0" : 12, "1" : 12 } } } >
    • Execution Team 2022-05-30, Execution Team 2022-06-13
    • 76

    Description

      The time-series bucket _id field contains bucket min time, which is held as an ObjectId in unix epoch form. Inserting dates prior to Jan 1st 1970 (which aren't supported by our ObjectId timestamp representation) leads to a value that represents a future date. It is possible to insert 2 measurements one with a pre-1970 date and one with a future date that are incorrectly included in the same bucket.

      Attachments

        Issue Links

          Activity

            People

              dan.larkin-york@mongodb.com Dan Larkin-York
              james.wahlin@mongodb.com James Wahlin
              Votes:
              0 Vote for this issue
              Watchers:
              10 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: