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

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

    • Type: Icon: Bug Bug
    • Resolution: Unresolved
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 5.0.0, 6.0.0, 7.0.0
    • Component/s: None
    • Catalog and Routing
    • ALL
    • v8.0, v7.3, v7.0, v6.0, v5.0
    • Hide
      db.createCollection("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("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("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("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)})
    • 2

      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. 

            Assignee:
            backlog-server-catalog-and-routing [DO NOT USE] Backlog - Catalog and Routing
            Reporter:
            enrico.golfieri@mongodb.com Enrico Golfieri
            Votes:
            0 Vote for this issue
            Watchers:
            8 Start watching this issue

              Created:
              Updated: