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

$collStats output does not include 'sharded' field

    • Type: Icon: Bug Bug
    • Resolution: Unresolved
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • Catalog and Routing
    • ALL
    • Hide

      Connect to a cluster using mongosh, and execute the following commands to confirm the issue:

      Enterprise [mongos] test> db.runCommand({collStats: 'users'})
      {
        sharded: false,
        // Full output omitted
      }
      
      Enterprise [mongos] test> db.users.aggregate([{$collStats: {}}])
      [
        {
          ns: 'test.users',
          shard: 'shard01',
          host: 'iceberg:27019',
          localTime: ISODate("2023-07-06T15:42:43.880Z")
        }
      ]
      
      Enterprise [mongos] test> var resp = db.users.aggregate([{$collStats: {storageStats: {}}}]).next();Enterprise [mongos] test> Object.keys(resp);
      [ 'ns', 'shard', 'host', 'localTime', 'storageStats' ]
      Enterprise [mongos] test> Object.keys(resp['storageStats']);
      [
        'size',        'count',
        'avgObjSize',  'numOrphanDocs',
        'storageSize', 'freeStorageSize',
        'capped',      'wiredTiger',
        'nindexes',    'indexDetails',
        'indexBuilds', 'totalIndexSize',
        'indexSizes',  'totalSize',
        'scaleFactor'
      ] 
      Show
      Connect to a cluster using mongosh, and execute the following commands to confirm the issue: Enterprise [mongos] test> db.runCommand({collStats: 'users'}) {   sharded: false, // Full output omitted } Enterprise [mongos] test> db.users.aggregate([{$collStats: {}}]) [   {     ns: 'test.users',     shard: 'shard01',     host: 'iceberg:27019',     localTime: ISODate("2023-07-06T15:42:43.880Z")   } ] Enterprise [mongos] test> var resp = db.users.aggregate([{$collStats: {storageStats: {}}}]).next();Enterprise [mongos] test> Object.keys(resp); [ 'ns', 'shard', 'host', 'localTime', 'storageStats' ] Enterprise [mongos] test> Object.keys(resp['storageStats']); [   'size',        'count',   'avgObjSize',  'numOrphanDocs',   'storageSize', 'freeStorageSize',   'capped',      'wiredTiger',   'nindexes',    'indexDetails',   'indexBuilds', 'totalIndexSize',   'indexSizes',  'totalSize',   'scaleFactor' ]
    • 2

      Output of the collStats command includes a boolean field sharded, which is true is the collection is sharded, and false otherwise.

      $collStats aggregation, that should be used instead of the deprecated collStats command does not include this field.

      Some products, including Mongoid and Doctrine ODMs relies on this field to detect whether a collection is sharded. We should have this field in the output of $collStats aggregation.

            Assignee:
            Unassigned Unassigned
            Reporter:
            dmitry.rybakov@mongodb.com Dmitry Rybakov
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: