Invalid collMod command with timeseries granularity change creates collection options inconsistency

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Unresolved
    • Priority: Major - P3
    • None
    • Affects Version/s: 6.0.0, 7.0.0, 8.0.0, 8.2.0-rc0, 8.1.0, 8.3.0-rc0
    • Component/s: None
    • None
    • Catalog and Routing
    • ALL
    • CAR Team To Be Assigned
    • 1
    • None
    • 3
    • TBD
    • 🟥 DDL
    • None
    • None
    • None
    • None
    • None
    • None

      In a sharded cluster, running a collMod command with both a timeseries granularity change, and another invalid option (e.g. setting a validator over a timeseries collection), over a tracked timeseries collection, for example:

      > db.adminCommand({shardcollection: "test.tscoll", key: {m: 1}, timeseries: {timeField: 't', metaField: 'm'}})
      > db.runCommand({collMod: "tscoll", timeseries: {granularity: "minutes"}, validator: {x: {$type: "string"}}})
      MongoServerError[InvalidOptions]: ...

       

      Fails but only after it has executed midway and created a collection options inconsistency:

      The timeseries granularity is updated on the global catalog (config.collections), but not on the local catalog (db.getCollectionInfos()):

      > db.getSiblingDB("config").collections.findOne({_id: "test.system.buckets.tscoll"}).timeseriesFields.granularity
      minutes
      > db.getCollectionInfos({name: "system.buckets.tscoll"})[0].options.timeseries.granularity
      seconds
      > db.checkMetadataConsistency()
      [...] 'CollectionOptionsMismatch' [...]

       

      This happens because the collMod coordinator does not validate the collMod command on its own, but rather relies on the primary shard validating the command during the kUpdateShards phase.

      However, this happens after the kUpdateConfig phase, where the granularity is updated on the global catalog.

              Assignee:
              Unassigned
              Reporter:
              Joan Bruguera Micó
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

                Created:
                Updated: