Problem Statement/Rationale
Calling db.collection.totalSize() on a collection that's around 1.7 terabytes returns a size of about 200 zettabytes. This seems to be because it's concatenating the values of storageSize and totalIndexSize as strings instead of adding them together.
Steps to Reproduce
- Have a collection that's large enough that storageSize returns a Long.
- Call db.collection.totalSize() on the collection
Expected Results
I expect the value to be storageSize and totalIndexSize added together as integers.
Actual Results
The number returned is far too large, and equal to storageSize and totalIndexSize concatenated as strings, instead of added together.
my-db> db["my-collection"].totalSize() 173274991001610559533056 my-db> db["my-collection"].storageSize() Long("1732749910016") my-db> db["my-collection"].totalIndexSize() 10559533056
Additional Notes
This seems to be because the code does storageSize + totalIndexSize, and adding a Long to an integer (or a Long to a Long) concatenates them instead of adding them.
my-db> Long("1") + 1 11 my-db> Long("1") + Long("1") 11 my-db> 1 + Long("1") 11 my-db> 1 + 1 2