Operational Defect Database

BugZero found this defect 318 days ago.

MongoDB | 2385070

$collStats output does not include 'sharded' field

Last update date:

3/14/2024

Affected products:

MongoDB Server

Affected releases:

No affected releases provided.

Fixed releases:

No fixed releases provided.

Description:

Info

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.

Top User Comments


Steps to Reproduce

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' ]

Additional Resources / Links

Share:

BugZero® Risk Score

What's this?

Coming soon

Status

Backlog

Learn More

Search:

...