Uploaded image for project: 'MongoDB Shell'
  1. MongoDB Shell
  2. MONGOSH-1447

getShardDistribution does not support sharded time series collections

    • Type: Icon: Bug Bug
    • Resolution: Unresolved
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • Labels:
      None
    • 3

      When the getShardDistribution command is invoked on a sharded time series collection, the output says that the collection is not actually sharded:

      [direct: mongos] mydb> db.weather.getShardDistribution()
      MongoshInvalidInputError: [SHAPI-10001] Collection weather is not sharded
      

      On the other hand, if the user invokes the same command on the related bucket collection, it produces an incorrect output:

      [direct: mongos] mydb> db.system.buckets.weather.getShardDistribution()
      TypeError: Cannot use 'in' operator to search for 'toNumber' in undefined

      The problems that I see are essentially two:

      • Obviously, the incorrect command result on the bucket collection
      • User are typically unaware of how time series collections are implemented and therefore are unaware of bucket collections

      Since the user has created a sharded time series collection, the expectation is that calling the getShardDistribution command on that collection will report the correct sharding information, which is actually obtained from the related (under the hood) bucket collection.

      To do that, the command should:

      1. Check that the collection is actually sharded by querying the config.collections collection
      2. If the collection is not present (because it's probably a time series), check that the related bucket collection is available in the config.collections collection
      3. Retrieve shard distribution information on the found sharded collection

            Assignee:
            Unassigned Unassigned
            Reporter:
            antonio.fuschetto@mongodb.com Antonio Fuschetto
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated: