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

A $_internalAllCollectionStats followed by $project may miss fields

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

      The internal aggregation stage $_internalAllCollectionStats applies an optimization in case of having a $project stage behind. This optimization may prevent the aggregation from delivering the storageStats field even when it's requested.

      This is an example where we don't get the expected output:

      > db.getSiblingDB("admin").aggregate([
          { $_internalAllCollectionStats: { stats: { storageStats: {} } } },    
          {$match:{ns:"dba.collB"}},
          {$project:{"storageStats":1}}
      ])
      
      [ { ns: "dba.collB", storageStats: {} } ]

       

      This is an example where we get the expected output:

      > db.getSiblingDB("admin").aggregate([
          { $_internalAllCollectionStats: { stats: { storageStats: {} } } }, 
          {$match:{ns:"dba.collB"}},
          {$project:{"storageStats.count":1}}
      ])
      
      [ { ns: "dba.collB", storageStats: { count: 1 } } ]

       

      This bug doesn't affect the final user because this is just an internal aggregation stage used by the $shardedDataDistribution aggregation stage. However, it could cause future bugs if we decide to change the $shardedDataDistribution pipeline in the future.

            Assignee:
            Unassigned Unassigned
            Reporter:
            silvia.surroca@mongodb.com Silvia Surroca
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: