[SERVER-67816] Time-series bucket rounding for pre-1970 dates behaves unexpectedly Created: 06/Jul/22  Updated: 07/Jun/23

Status: Open
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Dan Larkin-York Assignee: Backlog - Storage Execution Team
Resolution: Unresolved Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
related to SERVER-77888 Timeseries last-point query is incorr... Backlog
related to SERVER-77889 Timeseries sharded on time can route ... Backlog
related to SERVER-67825 Investigate where time-series functio... Closed
Assigned Teams:
Storage Execution
Operating System: ALL
Sprint: Execution Team 2022-10-17, Execution Team 2022-10-31, Execution Team 2022-11-14, Execution Team 2022-11-28
Participants:

 Description   

Instead of rounding timestamps down as expected, the server will round the bucket's minimum timestamp up for pre-1970 dates. (More accurately, it rounds the timestamp, expressed as an offset from the Unix epoch, towards zero.) This can result in incorrect control.min time values.



 Comments   
Comment by David Percy [ 07/Jun/23 ]

This can result in incorrect control.min time values.

It looks like the min/max time are still valid bounds: that range still includes every event in the bucket. For example:

> db.createCollection('ts', {timeseries:{timeField:'t',metaField:'m'}})
{ "ok" : 1 }
> db.ts.insert({t: ISODate('1969-01-01T00:00:12.345')})
WriteResult({ "nInserted" : 1 })
> db.system.buckets.ts.find().pretty()
{
        "_id" : ObjectId("fe1eccbc6f22cc96f1dd557f"),
        "control" : {
                "min" : {
                        // Tight lower bound, not rounded.
                        "t" : ISODate("1969-01-01T00:00:12.345Z")
                },
                "max" : {
                        // Rounded upper bound, not tight.
                        "t" : ISODate("1969-01-01T00:01:00Z")
                }
        },
        "data" : ...
}

So this breaks a couple other assumptions:

  • control.min.time is not rounded (This affects routing: SERVER-77889.)
  • control.min.time is not equal to the time encoded in _id
  • control.max.time is not a tight bound (This affect last-point queries: SERVER-77888.)
Generated at Thu Feb 08 06:09:08 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.