Uploaded image for project: 'MongoDB Shell'
  1. MongoDB Shell
  2. MONGOSH-1329

Bad arithmetic on getShardDistribution

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 1.6.1
    • Affects Version/s: None
    • Component/s: sh
    • None
    • 2
    • Iteration Porpoise
    • Not Needed

      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.

            Assignee:
            anna.henningsen@mongodb.com Anna Henningsen
            Reporter:
            jordi.serra-torrens@mongodb.com Jordi Serra Torrens
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: