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

Timeseries sharded on time can route pre-1970 inserts incorrectly

    • Type: Icon: Bug Bug
    • Resolution: Duplicate
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • Query Integration
    • ALL

      Timeseries collections can include time and/or metadata in the shard key. A key assumption mongos makes is that whenever an insert creates a bucket, the 'control.min.time' is initialized by rounding the even time.

      However, inserting events before 1970 results in a non-rounded 'control.min.time' value:

      > 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" : ...
      }
      

      If a shard owns the rounded value, but not the actual non-rounded 'control.min.time' value, then this bucket is now an orphan. Shard-filtering queries exclude it, and presumably the balancer could delete it at some point.

      Note that this is unrelated to time-series filter pushdown rewrites. The problem is that the insert path creates orphan buckets; queries will exclude those orphans regardless of optimization.

            Assignee:
            backlog-query-integration [DO NOT USE] Backlog - Query Integration
            Reporter:
            david.percy@mongodb.com David Percy
            Votes:
            0 Vote for this issue
            Watchers:
            7 Start watching this issue

              Created:
              Updated:
              Resolved: