[SERVER-56780] [4.4] mongod collStats does not handle large values for scale Created: 08/May/21  Updated: 29/Oct/23  Resolved: 25/May/21

Status: Closed
Project: Core Server
Component/s: Storage
Affects Version/s: 4.4.5
Fix Version/s: 4.4.7

Type: Bug Priority: Major - P3
Reporter: Benety Goh Assignee: Benety Goh
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
is related to SERVER-54470 Add $collStats aggregate pipeline sta... Closed
is related to SERVER-56689 mongos collStats does not handle larg... Closed
is related to SERVER-52545 Specify input/output to listIndexes c... Closed
is related to SERVER-43902 Apply scaling for totalIndexSize afte... Closed
Backwards Compatibility: Fully Compatible
Operating System: ALL
Sprint: Execution Team 2021-05-17, Execution Team 2021-05-31
Participants:

 Description   

When the collStats command is given a scale value that is too large for the integer type, a 4.4 server may fail with a BadValue error. This behavior was addressed in 4.9 and 5.0 when the collStats option handling was converted to using a IDL-generated parser that uses BSONElement::safeNumberInt().

4.4.5:
 
> db.t.insert({_id: 0})
WriteResult({ "nInserted" : 1 })
> db.t.stats().storageSize
4096
> db.t.stats(100).storageSize
40
> db.t.stats(Number.MAX_VALUE).storageSize
> db.t.stats(Number.MAX_VALUE)
{ "ns" : "test.t", "ok" : 0, "errmsg" : "scale has to be >= 1" }
 
4.9.0-rc1:
 
> db.t.insert({_id: 0})
WriteResult({ "nInserted" : 1 })
> db.t.stats().storageSize
4096
> db.t.stats(100).storageSize
40
> db.t.stats(Number.MAX_VALUE).storageSize
0



 Comments   
Comment by Githook User [ 22/May/21 ]

Author:

{'name': 'Benety Goh', 'email': 'benety@mongodb.com', 'username': 'benety'}

Message: SERVER-56780 re-enable apitest_dbcollection.js in multiversion fixture
Branch: master
https://github.com/mongodb/mongo/commit/2f9ad0ee82124af66af3b39adb594c81a73c296e

Comment by Githook User [ 19/May/21 ]

Author:

{'name': 'Benety Goh', 'email': 'benety@mongodb.com', 'username': 'benety'}

Message: SERVER-56780 SERVER-56689 add collStats test cases for large scale values

(partially cherry picked from commit 6ed5810685550369429efae6a175b163e8a111a5)
Branch: v4.4
https://github.com/mongodb/mongo/commit/9d1b28dc920d7e802ae631b130590d0a53da071c

Comment by Githook User [ 19/May/21 ]

Author:

{'name': 'Benety Goh', 'email': 'benety@mongodb.com', 'username': 'benety'}

Message: SERVER-56780 mongod collStats handles large scale values
Branch: v4.4
https://github.com/mongodb/mongo/commit/00d613fe95f90079f9775cd25ea82d148ab0179b

Comment by Githook User [ 18/May/21 ]

Author:

{'name': 'Benety Goh', 'email': 'benety@mongodb.com', 'username': 'benety'}

Message: SERVER-56780 SERVER-52545 add BSONElement::safeNumberInt()

(partially cherry picked from commit b83bf99b6e48e2f41ea3b1e7ed6aeb4cf1eb0d31)
Branch: v4.4
https://github.com/mongodb/mongo/commit/cc1640581318df61a5fedc5c7ddd1a91c13e0712

Comment by Benety Goh [ 08/May/21 ]

This issue was discovered while merging SERVER-56689.

The IDL conversion for closest in 5.0 was done in SERVER-54470.

BSONElement::safeNumberInt() was added in 5.0 during SERVER-52545 and is not currently available in 4.4.

The mongos collStats in 5.0 is also quite different from 4.4 due to recent improvements made in SERVER-43902.

Generated at Thu Feb 08 05:40:11 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.