[SERVER-63126] Can create a view that seems (to listCollections) to be a time series collection Created: 29/Jan/22  Updated: 29/Oct/23  Resolved: 05/May/22

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: 5.0.5
Fix Version/s: 6.1.0-rc0

Type: Bug Priority: Major - P3
Reporter: Wojciech Waga Assignee: Dan Larkin-York
Resolution: Fixed Votes: 0
Labels: read-only-views, time-series
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
Documented
is documented by DOCS-15322 Server: Investigate changes in SERVER... Closed
Problem/Incident
Related
related to SERVER-77397 Investigate manually creating timeser... Open
Backwards Compatibility: Minor Change
Operating System: ALL
Steps To Reproduce:

db> db.createView("view1","something",[])
{ ok: 1 }
db> db.createView("view2","system.buckets.time",[]) 
{ ok: 1 }
db> show collections
view1 [view]
view2 [time-series]     <----- looks like a valid time series but it's not
system.views
db> db.createCollection("time",{timeseries:{timeField:"time"}})
{ ok: 1 }
db> show collections
time [time-series]  <---- this makes view2 to disappear although still being present in the system.views
view1 [view]
system.buckets.time
system.views
db> db.time.drop()
true
db> show collections
view1 [view]
view2 [time-series]    <-- dropping "time" brings view2 back to the list
system.views

Sprint: Execution Team 2022-05-02, Execution Team 2022-05-16
Participants:
Linked BF Score: 68

 Description   

I thing the intention behind hiding custom views on time series collections was to disallow manual creation of those. For now you can create them and they behave oddly.
 

 



 Comments   
Comment by Githook User [ 23/May/23 ]

Author:

{'name': 'Shin Yee Tan', 'email': 'shinyee.tan@mongodb.com', 'username': 'shinyeet'}

Message: Revert "SERVER-63126 Prevent creating view on system.buckets namespace"

This reverts commit 0951b7a34980b6257eb33b8129dcc5c32b98e5e9.
Branch: master
https://github.com/mongodb/mongo/commit/9dfd76f3a2afc1362a48f784ecda84745dac77ba

Comment by Githook User [ 23/May/23 ]

Author:

{'name': 'Shin Yee Tan', 'email': 'shinyee.tan@mongodb.com', 'username': 'shinyeet'}

Message: Revert "SERVER-63126 Prevent creating view on system.buckets namespace"

This reverts commit 0951b7a34980b6257eb33b8129dcc5c32b98e5e9.
Branch: v7.0
https://github.com/mongodb/mongo/commit/0d35ff6512b911464cd0937467a351267716cdab

Comment by Githook User [ 05/May/22 ]

Author:

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

Message: SERVER-63126 Prevent creating view on system.buckets namespace
Branch: master
https://github.com/mongodb/mongo/commit/0951b7a34980b6257eb33b8129dcc5c32b98e5e9

Comment by Eric Sedor [ 31/Jan/22 ]

Thanks, a few observations:

  • Creating a time series collection when a name-colliding bucket collection already exists fails with an error Bucket Collection already exists
  • Creating a view on a name-colliding bucket collection that does not exist succeeds and creates confusing output in listCollections, such that the view is described as having {{type: "timeseries" even though a bucket collection does not exist. mongosh represents this in good faith as a time series collection in "show collections"

replset [direct: primary] test> db.createView("view2","system.buckets.time",[])
{ ok: 1 }
replset [direct: primary] test> db.runCommand("listCollections")
{
  cursor: {
    id: Long("0"),
    ns: 'test.$cmd.listCollections',
    firstBatch: [
      {
        name: 'system.views',
        type: 'collection',
        options: {},
        info: {
          readOnly: false,
          uuid: UUID("39198dd0-e966-4097-ad4a-18c4c546dbb2")
        },
        idIndex: { v: 2, key: { _id: 1 }, name: '_id_' }
      },
      {
        name: 'view2',
        type: 'timeseries',
        options: {},
        info: { readOnly: false }
      }
    ]
  },
  ok: 1,
  '$clusterTime': {
    clusterTime: Timestamp(2, 1643666180),
    signature: {
      hash: Binary(Buffer.from("0000000000000000000000000000000000000000", "hex"), 0),
      keyId: Long("0")
    }
  },
  operationTime: Timestamp(2, 1643666180)
}

  • The confusion only grows for mongosh after the time series collection is created and further mangling of "show collections" occurs, but from the above we do see that the confusion is not just on the mongosh side.

I'll pass this to an appropriate team to consider the right course of action here.

Thank you!

Comment by Wojciech Waga [ 31/Jan/22 ]

Hi @Eric Sedor. This was the only context I observed this so far.

Comment by Eric Sedor [ 31/Jan/22 ]

Hi wojciech.waga@gmail.com, to clarify, have you observed this behavior in any other circumstance than with creating a view on "system.buckets.time" prior to creating a time series collection with the name "time"?

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