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

Prevent sharding/moving a time-series buckets collection without the 'timeseries' options on FCV 8.0+

    • Type: Icon: Improvement Improvement
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 8.1.0-rc0
    • Affects Version/s: 8.1.0-rc0, 8.0.0
    • Component/s: Catalog, Sharding
    • None
    • Catalog and Routing
    • Fully Compatible
    • v8.0
    • CAR Team 2025-01-20, CAR Team 2025-02-03
    • 1

      MongoDB 8.0+ forbids creating time-series buckets collections without the 'timeseries' options field as part of SERVER-79630. Around the same time, shardCollection was redesigned as part of SERVER-78918, so that a new DDL coordinator is used after an upgrade to FCV 8.0.

      However, time-series buckets collections without the 'timeseries' options field can still be created if the feature flag associated to this functionality is disabled. After this happens, running a shardCollection command in FCV 8.0 targeting the main namespace will shard the buckets collection without 'timeseries' options. In contrast, the old shardCollection command from FCV 7.0 returns an error without sharding the collection:

      [direct: mongos] test> // NOTE: Shards must have been launched with mongod --setParameter featureFlagDisallowBucketCollectionWithoutTimeseriesOptions=false
      
      [direct: mongos] test> db.createCollection("system.buckets.withoutoptions")
      { ok: 1 }
      [direct: mongos] test> db.adminCommand({setFeatureCompatibilityVersion: "7.0", confirm: true})
      {
        ok: 1, [...]
      }
      [direct: mongos] test> db.adminCommand({shardCollection: "test.withoutoptions", key: {m:1}})
      MongoServerError[Location6159000]: the collection 'test.system.buckets.withoutoptions' does not have 'timeseries' options
      [direct: mongos] test> db.adminCommand({setFeatureCompatibilityVersion: "8.0", confirm: true})
      {
        ok: 1, [...]
      }
      [direct: mongos] test> db.adminCommand({shardCollection: "test.withoutoptions", key: {m:1}})
      {
        collectionsharded: 'test.withoutoptions',
        ok: 1, [...]
      }
      

       

      Similarly, moveCollection will also track the collection in the cluster catalog:

      [direct: mongos] test> db.createCollection("system.buckets.withoutoptions")
      { ok: 1 }
      [direct: mongos] test> db.adminCommand({moveCollection: "test.withoutoptions", toShard: "shard02"})
      MongoServerError[NamespaceNotFound]: Expected collection test.withoutoptions to be tracked
      [direct: mongos] test> db.getSiblingDB("config").collections.find({_id: {$regex: /^test\./}})
      [
        {_id: 'test.system.buckets.withoutoptions', [...], unsplittable: true}
      ]
      

       

      Add a guardrail so that we never track a time-series bucket collections without the 'timeseries' field when using the shardCollection / moveCollection command in any FCV version.

            Assignee:
            joan.bruguera-mico@mongodb.com Joan Bruguera Micó
            Reporter:
            joan.bruguera-mico@mongodb.com Joan Bruguera Micó
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: