Once a sharded collection has been successfully dropped, operations on it should be identical to if it had never existed, and to if it was to be implicitly re-created as a new unsharded collection. However, after a sharded collection has been dropped, db.coll.getShardDistribution() reports the error "Unable to retrieve storageStats in $collStats stage: Collection [test.test] not found." instead of the expected message "Collection test.test is not sharded." (which is the message obtained if the collection had never previously existed, or had previously existed but unsharded).
Original summary: getShardDistribution() erroneously reports "Collection XYZ is not sharded"
Original description:
If collStats exceeds the maxBSONSize of 16MB due to a lot of shard metadata, getShardDistribution() erroneously reports that the collection is not sharded. This is caused by the function not checking for an error in the collStats command:
> db.COLL.getShardDistribution function () { var stats = this.stats(); if (!stats.sharded) { print("Collection " + this + " is not sharded."); return; } ... logic to print shard stats ...
The stats.sharded property doesn't exist if stats contains an error message, which is why getShardDistribution() reports a collection as unsharded if its shard metadata causes the collStats command to fail.
- related to
-
SERVER-43689 getShardDistribution() incorrectly shows 0 chunks
- Closed
-
SERVER-44891 collStats will fail if resulting BSON size > 16MB
- Closed
-
SERVER-44892 getShardDistribution should use $collStats agg stage instead of collStats command
- Closed