[SERVER-58171] Changing time-series granularity does not update view definition Created: 30/Jun/21  Updated: 29/Oct/23  Resolved: 14/Jul/21

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: 5.0.0-rc6
Fix Version/s: 5.0.1, 5.1.0-rc0

Type: Bug Priority: Critical - P2
Reporter: Louis Williams Assignee: Dan Larkin-York
Resolution: Fixed Votes: 0
Labels: read-only-views
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Backports
Related
related to SERVER-58350 Fix disabled Storage tests failing in... Closed
is related to SERVER-58186 [5.0] Temporarily disallow collMod fr... Closed
Backwards Compatibility: Fully Compatible
Operating System: ALL
Backport Requested:
v5.0
Sprint: Execution Team 2021-07-12, Execution Team 2021-07-26
Participants:

 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.



 Comments   
Comment by Vivian Ge (Inactive) [ 06/Oct/21 ]

Updating the fixversion since branching activities occurred yesterday. This ticket will be in rc0 when it’s been triggered. For more active release information, please keep an eye on #server-release. Thank you!

Comment by Githook User [ 14/Jul/21 ]

Author:

{'name': 'Dan Larkin-York', 'email': 'dan.larkin-york@mongodb.com', 'username': 'dhly-etc'}

Message: SERVER-58171 Changing time-series granularity does not update view definition
Branch: v5.0
https://github.com/mongodb/mongo/commit/3b9982be740bc360691f46ed534427065763c16f

Comment by Githook User [ 14/Jul/21 ]

Author:

{'name': 'Dan Larkin-York', 'email': 'dan.larkin-york@mongodb.com', 'username': 'dhly-etc'}

Message: SERVER-58171 Changing time-series granularity does not update view definition
Branch: master
https://github.com/mongodb/mongo/commit/1f0278ec2362f0796929cb6a0fa9c74072455831

Generated at Thu Feb 08 05:43:46 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.