[SERVER-24441] Change geo_full.js to not create points near the poles Created: 07/Jun/16  Updated: 17/Nov/16  Resolved: 10/Jun/16

Status: Closed
Project: Core Server
Component/s: Geo
Affects Version/s: None
Fix Version/s: 3.0.13, 3.2.8, 3.3.9

Type: Task Priority: Major - P3
Reporter: Max Hirschhorn Assignee: Max Hirschhorn
Resolution: Done Votes: 0
Labels: test-only
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: File geo_2d_2dsphere_parity.js    
Issue Links:
Depends
Related
related to SERVER-24440 Points near the poles may fail to be ... Backlog
Backwards Compatibility: Fully Compatible
Backport Completed:
Sprint: Query 16 (06/24/16)
Participants:
Linked BF Score: 0

 Description   

Until SERVER-24440 is fixed, points near the poles may fail to be returned by a $nearSphere when a "2d" index is used. We should change the pointIsOK() function in the geo_full.js test to only create points that have latitudes in [-89, 89].

if ((startPoint[1] + distDegrees > 90) || (startPoint[1] - distDegrees < -90)) {
    return false;
}



 Comments   
Comment by Githook User [ 10/Jun/16 ]

Author:

{u'username': u'visemet', u'name': u'Max Hirschhorn', u'email': u'max.hirschhorn@mongodb.com'}

Message: SERVER-24441 Avoid creating points near the poles in geo_full.js.

(cherry picked from commit 3ee21ae53b1aedf0820e627f37cf502871e7a0d2)
Branch: v3.0
https://github.com/mongodb/mongo/commit/98009524ca86f9e63b3865d55638630e3985d34e

Comment by Githook User [ 10/Jun/16 ]

Author:

{u'username': u'visemet', u'name': u'Max Hirschhorn', u'email': u'max.hirschhorn@mongodb.com'}

Message: SERVER-24441 Avoid creating points near the poles in geo_full.js.

(cherry picked from commit 3ee21ae53b1aedf0820e627f37cf502871e7a0d2)
Branch: v3.2
https://github.com/mongodb/mongo/commit/46246b250f3573bf662f5503d3fd0352f7cf776a

Comment by Githook User [ 10/Jun/16 ]

Author:

{u'username': u'visemet', u'name': u'Max Hirschhorn', u'email': u'max.hirschhorn@mongodb.com'}

Message: SERVER-24441 Avoid creating points near the poles in geo_full.js.
Branch: master
https://github.com/mongodb/mongo/commit/3ee21ae53b1aedf0820e627f37cf502871e7a0d2

Comment by Max Hirschhorn [ 09/Jun/16 ]

I wrote the geo_2d_2dsphere_parity.js test to directly compare the results of the same $nearSphere query with the same inserted data of a "2d" and "2dsphere" index to try and identify any other possible gaps in behavior when answering spherical queries using a "2d" index. I have been able to attribute all failures as being instances of SERVER-21594 or SERVER-24440.

In order to convince myself that the change from 90 degrees to 89 degrees in the geo_full.js test is sufficient to avoid spuriously triggering SERVER-24440, I applied the following patch to the attached geo_2d_2dsphere_parity.js test. The patch causes only points between 88 and 89 degrees latitude to be generated, while rejecting points with latitudes greater than 89 degrees or less than -89 degrees (after accounting for the error margin). It doesn't seem to fail.

diff --git a/jstests/noPassthrough/geo_2d_2dsphere_parity.js b/jstests/noPassthrough/geo_2d_2dsphere_parity.js
index 0e3d1d1..055f646 100644
--- a/jstests/noPassthrough/geo_2d_2dsphere_parity.js
+++ b/jstests/noPassthrough/geo_2d_2dsphere_parity.js
@@ -18,7 +18,7 @@
     }
 
     function getRandomPoint() {
-        return [Random.rand() * 360 - 180, Random.rand() * 180 - 90];
+        return [Random.rand() * 360 - 180, 89 - Random.rand()];
     }
 
     function convertDegreesToRadians(degrees) {
@@ -64,7 +64,7 @@
         var error = computeErrorMarginForPoint(env);
         var distDegrees = convertRadiansToDegrees(radius) + error;
         // Cap should not include the South/North Pole.
-        if ((startPoint[1] + distDegrees > 90) || (startPoint[1] - distDegrees < -90)) {
+        if ((startPoint[1] + distDegrees > 89) || (startPoint[1] - distDegrees < -89)) {
             return false;
         }
         var xscandist = computexscandist(startPoint[1], distDegrees);
@@ -189,9 +189,9 @@
 
             // XXX: This assertion can fail if the shortest distance between the center and the
             // points in the document is computed by crossing a pole or the anti-meridian.
-            assert.eq(results2d,
-                      results2dsphere,
-                      "Near sphere query: sphere center: " + query.sphereCenter);
+            // assert.eq(results2d,
+            //           results2dsphere,
+            //           "Near sphere query: sphere center: " + query.sphereCenter);
         }
     }
 

Generated at Thu Feb 08 04:06:22 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.