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

Changing time-series granularity does not update view definition

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Critical - P2
    • Resolution: Fixed
    • Affects Version/s: 5.0.0-rc6
    • Fix Version/s: 5.0.1, 5.1.0-rc0
    • Component/s: None
    • Labels:
    • Backwards Compatibility:
      Fully Compatible
    • Operating System:
      ALL
    • Backport Requested:
      v5.0
    • Sprint:
      Execution Team 2021-07-12, Execution Team 2021-07-26

      Description

      If the time-series granularity is increased via 'collMod', newly generated buckets will occupy larger time ranges. This means that queries on time fields also need to start considering larger ranges when scanning. That is currently not the case, as the bucketMaxSpanSeconds is hardcoded into the view pipeline, but it also needs to be updated in collMod.

      The result of this bug is that queries will return incorrect results on time-series collections that have modified their 'granularity' setting with 'collMod'.

       

      > db.createCollection("ts", {timeseries: {timeField: 't', granularity: 'seconds'}})
      { "ok" : 1 }
      > db.runCommand({listCollections: 1, filter: {name: 'ts'}})
      {
              "cursor" : {
                      "id" : NumberLong(0),
                      "ns" : "test.$cmd.listCollections",
                      "firstBatch" : [
                              {
                                      "name" : "ts",
                                      "type" : "timeseries",
                                      "options" : {
                                              "timeseries" : {
                                                      "timeField" : "t",
                                                      "granularity" : "seconds",
                                                      "bucketMaxSpanSeconds" : 3600
                                              }
                                      },
                                      "info" : {
                                              "readOnly" : false
                                      }
                              }
                      ]
              },
              "ok" : 1
      }
      > db.system.views.find()
      { "_id" : "test.ts", "viewOn" : "system.buckets.ts", "pipeline" : [ { "$_internalUnpackBucket" : { "timeField" : "t", "bucketMaxSpanSeconds" : 3600, "exclude" : [ ] } } ] }
      > db.runCommand({collMod: 'ts', timeseries: {granularity: 'minutes'}})
      { "ok" : 1 }
      > db.runCommand({listCollections: 1, filter: {name: 'ts'}})
      {
              "cursor" : {
                      "id" : NumberLong(0),
                      "ns" : "test.$cmd.listCollections",
                      "firstBatch" : [
                              {
                                      "name" : "ts",
                                      "type" : "timeseries",
                                      "options" : {
                                              "timeseries" : {
                                                      "timeField" : "t",
                                                      "granularity" : "minutes",
                                                      "bucketMaxSpanSeconds" : 86400
                                              }
                                      },
                                      "info" : {
                                              "readOnly" : false
                                      }
                              }
                      ]
              },
              "ok" : 1
      }
      > db.system.views.find()
      { "_id" : "test.ts", "viewOn" : "system.buckets.ts", "pipeline" : [ { "$_internalUnpackBucket" : { "timeField" : "t", "bucketMaxSpanSeconds" : 3600, "exclude" : [ ] } } ] }
      

      Notice that the metadata for the time-series collection is updated, but not the view pipeline.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              dan.larkin-york Dan Larkin-York
              Reporter:
              louis.williams Louis Williams
              Participants:
              Votes:
              0 Vote for this issue
              Watchers:
              9 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: