[SERVER-58358] Datasize command does not validate the syntax and can cause major performance degradation Created: 07/Jul/21 Updated: 29/Oct/23 Resolved: 07/Jan/22 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | None |
| Affects Version/s: | 4.2.12 |
| Fix Version/s: | 5.3.0 |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Ivan Grigolon | Assignee: | Davis Haupt (Inactive) |
| Resolution: | Fixed | Votes: | 3 |
| Labels: | neweng, sharding-nyc-subteam2 | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||||||||||||||||||||||||
| Backwards Compatibility: | Fully Compatible | ||||||||||||||||||||||||||||||
| Operating System: | ALL | ||||||||||||||||||||||||||||||
| Steps To Reproduce: | Create some sample document with just _id
This is the command as it was run
This is instead the correct syntax to use
I believe however that, the command should have prompted an error communicating the malformed syntax. |
||||||||||||||||||||||||||||||
| Participants: | |||||||||||||||||||||||||||||||
| Case: | (copied to CRM) | ||||||||||||||||||||||||||||||
| Linked BF Score: | 177 | ||||||||||||||||||||||||||||||
| Story Points: | 2 | ||||||||||||||||||||||||||||||
| Description |
|
If the command does not specify any of the options below:
It is assumed that the user is aware that the command is going to scan the entire collection, which is ok. If the command is executed incorrectly without the "keyPattern" field but just using min/max:
the command is still executed on the entire collection, so there is no validation of what the user was really intending to do, which is to run datasize on a particular indexed field. This can cause outages in large deployment, especially because datasize command cannot be killed ( I believe the command should: Steps to reproduce below: |
| Comments |
| Comment by Githook User [ 06/Jan/22 ] |
|
Author: {'name': 'Davis Haupt', 'email': 'davis.haupt@mongodb.com', 'username': 'davish'}Message: |
| Comment by Davis Haupt (Inactive) [ 21/Dec/21 ] |
|
After some investigation, it seems like the command in the ticket is malformed not because it is missing a keyPatterm, but because the min and max keys are malformed. If the keyPattern is empty, then it is inferred based on the min key bound (https://github.com/10gen/mongo/blob/master/src/mongo/db/commands/dbcommands.cpp#L370). In the example, the min and max were NumberInts. However, dataSize is expecting an object that represents the lower and upper bounds of the key range based on some index, rather than a min and max value for some field. |
| Comment by Connie Chen [ 12/Nov/21 ] |
|
Passing this to Sharding NYC to review as this is not catalog-related. |