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

Creating a bucket collection with timeseries option doesn't create the view

    XMLWordPrintableJSON

Details

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Major - P3 Major - P3
    • None
    • None
    • None
    • None
    • Catalog and Routing
    • ALL
    • Hide

      db.createCollection("test.system.buckets.coll", timeseries:{timeField:"timestamp", metaField: "metadata"});
      assert.commandWorked(db.createCollection("test.coll"));
       
      // Insert fails as the json format is not the one expected (the insert is re-directed into system.buckets.coll)
      let coll = db.getCollection("test.coll")
      assert.commandFailed(coll.insert({x: 1}));
       
      // Insert a document with the correct format will cause a crash of the mongod node
      coll.insert({metadata:1,timestamp:ISODate(0,0)})

      Show
      db.createCollection("test.system.buckets.coll", timeseries:{timeField:"timestamp", metaField: "metadata"}); assert.commandWorked(db.createCollection("test.coll"));   // Insert fails as the json format is not the one expected (the insert is re-directed into system.buckets.coll) let coll = db.getCollection("test.coll") assert.commandFailed(coll.insert({x: 1}));   // Insert a document with the correct format will cause a crash of the mongod node coll.insert({metadata:1,timestamp:ISODate(0,0)})

    Description

      Currently creating a bucket collection "test.system.buckets.coll" with timeseries options creates the collection as a timeseries but doesn't create the related view.

      As a consequence, creating another collection with the view namespace "test.coll" works.

      This is problematic because any reference to "test.coll" is now routed to the bucket namespace, causing all the insert to fail as they require the "timestamp" field.

      However, writing in that collection is not safe, and even a insert using the "expected" format will cause the primary node to crash

      Possible solution:

      A solution could be to force the  creation of the related view when a user inserts a bucket collection with timeseries options.

      This would simplify the reasoning behind creating a collection which is supposed to be internal. This would also cause the second create to return NamespaceExists and solve this specific bug.

      Note this refers specifically to a bucket namespace with timeseries options, without the timeseries options the collection should be treated as a normal collection. 

      Attachments

        Activity

          People

            backlog-server-catalog-and-routing Backlog - Catalog and Routing
            enrico.golfieri@mongodb.com Enrico Golfieri
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

            Dates

              Created:
              Updated: