-
Type:
Bug
-
Resolution: Unresolved
-
Priority:
Major - P3
-
None
-
Affects Version/s: None
-
Component/s: None
-
Catalog and Routing
-
ALL
-
2
-
🟦 Shard Catalog
-
None
-
None
-
None
-
None
-
None
-
None
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.