Problem Statement/Rationale
What is going wrong? What action would you like the Engineering team to take?
`getShardDistribution` runs $collStats on all shards and then aggragates the results. To compute the total `count` of documents, it sums the `count` returned by each shard. $collStats uses the smallest possible type to report `count` (e.g. a plain integer if small, a Long if larger, etc.). When mongosh sums a plain integer with a Long, the result is concatenated, rather than summed. Thus, the reported count is incorrect.
e.g.
> 10 + NumberLong('1') 101
The same issue happens with the 'data' size field.
Please be sure to attach relevant logs with any sensitive data redacted.
Steps to Reproduce
How could an engineer replicate the issue you’re reporting?
Create a sharded collection, where one shard has a number of documents greater than 2^32, and the other has a smaller number of documents.
Expected Results
What do you expect to happen?
getShardDistribution is expected to return a correct total count.
Actual Results
What do you observe is happening?
getShardDistribution will return an incorrect 'total count'.
Additional Notes
Any additional information that may be useful to include.
- related to
-
SERVER-71543 `sh.getShardDistribution` concatenates strings instead of summing number of docs
- Closed