[SERVER-47994] Fix for numerical overflow in GeoHash Created: 06/May/20 Updated: 29/Oct/23 Resolved: 18/May/20 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Querying |
| Affects Version/s: | 4.3.6 |
| Fix Version/s: | 4.0.19, 3.6.19, 4.2.8, 4.4.0-rc7, 4.7.0 |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Svilen Mihaylov (Inactive) | Assignee: | Svilen Mihaylov (Inactive) |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||||||||||||||||||
| Backwards Compatibility: | Fully Compatible | ||||||||||||||||||||||||
| Operating System: | ALL | ||||||||||||||||||||||||
| Backport Requested: |
v4.4, v4.2, v4.0, v3.6
|
||||||||||||||||||||||||
| Sprint: | Query 2020-05-18, Query 2020-06-01 | ||||||||||||||||||||||||
| Participants: | |||||||||||||||||||||||||
| Linked BF Score: | 18 | ||||||||||||||||||||||||
| Description |
|
Proposed title: Geo 2D index bounds validation Issue Status as of May 29, 2020 ISSUE SUMMARY Earlier versions allowed invalid values for the min and max parameters for 2d indexes.
USER IMPACT
RECOVERY STEPS
AFFECTED VERSIONS FIX VERSION |
| Comments |
| Comment by Githook User [ 21/May/20 ] | |||||||||||||||||||||||||||||
|
Author: {'name': 'Svilen Mihaylov', 'email': 'svilen.mihaylov@mongodb.com', 'username': 'smihaylov-mongodb'}Message: | |||||||||||||||||||||||||||||
| Comment by Githook User [ 21/May/20 ] | |||||||||||||||||||||||||||||
|
Author: {'name': 'Svilen Mihaylov', 'email': 'svilen.mihaylov@mongodb.com', 'username': 'smihaylov-mongodb'}Message: | |||||||||||||||||||||||||||||
| Comment by David Storch [ 20/May/20 ] | |||||||||||||||||||||||||||||
|
This issue can result in broken 2d indexes if the min and max are +/-infinity or NaN, or if min and max are very close together. Here's a simple example where min is provided as NaN:
It is a bug that such indexes can be created in the first place, although subsequent insertions of coordinate pairs will fail since they do not fall within the nonsensical interval of [NaN, 10]. A more severe problem occurs when min or max are infinite. Here's an example where min is set to -Infinity:
In this case, the insert of coordinate pair data succeeds, but subsequent queries using the index fail to return results due to the corrupt index. Finally, a corrupt index can result if min and max are very close together. This is because the internal geo hash computation relies on a scaling factor so that values on [min, max] are mapped to [0, (max-min) * scaling]. The scaling factor is defined as numBuckets / (max - min), which can result in overflow. I suspect that there are very few users which actually have such invalid 2d indexes in the wild, since real use cases are unlikely to involve infinities, nans, and very tiny ranges of doubles. Users who are affected, however, should upgrade to a version containing the fix, drop any invalid 2d indexes, and rebuild indexes with legal parameters. | |||||||||||||||||||||||||||||
| Comment by Githook User [ 18/May/20 ] | |||||||||||||||||||||||||||||
|
Author: {'name': 'Svilen Mihaylov', 'email': 'svilen.mihaylov@mongodb.com', 'username': 'smihaylov-mongodb'}Message: | |||||||||||||||||||||||||||||
| Comment by Githook User [ 15/May/20 ] | |||||||||||||||||||||||||||||
|
Author: {'name': 'Svilen Mihaylov', 'email': 'svilen.mihaylov@mongodb.com', 'username': 'smihaylov-mongodb'}Message: | |||||||||||||||||||||||||||||
| Comment by Githook User [ 15/May/20 ] | |||||||||||||||||||||||||||||
|
Author: {'name': 'Svilen Mihaylov', 'email': 'svilen.mihaylov@mongodb.com', 'username': 'smihaylov-mongodb'}Message: | |||||||||||||||||||||||||||||
| Comment by Svilen Mihaylov (Inactive) [ 06/May/20 ] | |||||||||||||||||||||||||||||