[SERVER-19674] Fatal error calling createIndex with 2dsphere Created: 30/Jul/15  Updated: 17/Feb/21  Resolved: 14/Aug/15

Status: Closed
Project: Core Server
Component/s: Geo
Affects Version/s: 3.0.5
Fix Version/s: 3.1.7

Type: Bug Priority: Critical - P2
Reporter: Denis Taniguchi Assignee: Kevin Albertson
Resolution: Done Votes: 1
Labels: todo_in_code
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
is duplicated by SERVER-43422 Complete TODO listed in SERVER-19674 Closed
Related
related to SERVER-43422 Complete TODO listed in SERVER-19674 Closed
related to SERVER-44194 Complete TODO listed in SERVER-19674 Closed
is related to SERVER-19913 S2 should not make fatal assertions Backlog
Backwards Compatibility: Fully Compatible
Operating System: ALL
Steps To Reproduce:

use test
db.test.insert({
    "_id" : ObjectId("5579e78b6b599f4d7e0ae55e"),
    "location" : {
        "type" : "Polygon",
        "coordinates" : [ 
            [ 
                [ 
                    -45.0000000000000000, 
                    0.0000000000000000
                ], 
                [ 
                    -44.8750000000000000, 
                    0.0000000000000000
                ], 
                [ 
                    -44.8750000000000000, 
                    0.1250000000000000
                ], 
                [ 
                    -45.0000000000000000, 
                    0.1250000000000000
                ], 
                [ 
                    -45.0000000000000000, 
                    0.0000000000000000
                ]
            ]
        ]
    }
})
db.test.createIndex({"location":"2dsphere"})

Participants:

 Description   

On Windows servers, I get the following error when trying to create a 2dsphere index in my collection with one document having a specific location coordinate values.

2015-07-30T16:07:21.524-0300 F GEO      [initandlisten] src\third_party\s2\s2edgeutil.cc:54:  VertexCrossing called with 4 distinct vertices
2015-07-30T16:07:21.524-0300 I -        [initandlisten] Fatal Assertion 0
2015-07-30T16:07:22.179-0300 I CONTROL  [initandlisten] mongod.exe    ...\src\mongo\util\stacktrace_win.cpp(175)                      mongo::printStackTrace+0x43
2015-07-30T16:07:22.179-0300 I CONTROL  [initandlisten] mongod.exe    ...\src\mongo\util\log.cpp(135)                                 mongo::logContext+0x8f
2015-07-30T16:07:22.179-0300 I CONTROL  [initandlisten] mongod.exe    ...\src\mongo\util\assert_util.cpp(165)                         mongo::fassertFailed+0x77
2015-07-30T16:07:22.179-0300 I CONTROL  [initandlisten] mongod.exe    ...\src\third_party\s2\base\logging.cc(45)                      LogMessageFatal::~LogMessageFatal+0x2c
2015-07-30T16:07:22.179-0300 I CONTROL  [initandlisten] mongod.exe    ...\src\third_party\s2\s2edgeutil.cc(55)                        S2EdgeUtil::VertexCrossing+0x1dc
2015-07-30T16:07:22.180-0300 I CONTROL  [initandlisten] mongod.exe    ...\src\third_party\s2\s2loop.cc(421)                           S2Loop::Contains+0x1a0
2015-07-30T16:07:22.180-0300 I CONTROL  [initandlisten] mongod.exe    ...\src\third_party\s2\s2loop.cc(629)                           S2Loop::Intersects+0xce
2015-07-30T16:07:22.180-0300 I CONTROL  [initandlisten] mongod.exe    ...\src\third_party\s2\s2loop.cc(407)                           S2Loop::MayIntersect+0x7f
2015-07-30T16:07:22.180-0300 I CONTROL  [initandlisten] mongod.exe    ...\src\third_party\s2\s2polygon.cc(471)                        S2Polygon::MayIntersect+0x67
2015-07-30T16:07:22.180-0300 I CONTROL  [initandlisten] mongod.exe    ...\src\third_party\s2\s2regioncoverer.cc(95)                   S2RegionCoverer::NewCandidate+0x1a
2015-07-30T16:07:22.180-0300 I CONTROL  [initandlisten] mongod.exe    ...\src\third_party\s2\s2regioncoverer.cc(222)                  S2RegionCoverer::GetInitialCandidates+0x142
2015-07-30T16:07:22.180-0300 I CONTROL  [initandlisten] mongod.exe    ...\src\third_party\s2\s2regioncoverer.cc(255)                  S2RegionCoverer::GetCoveringInternal+0x123
2015-07-30T16:07:22.181-0300 I CONTROL  [initandlisten] mongod.exe    ...\src\third_party\s2\s2regioncoverer.cc(297)                  S2RegionCoverer::GetCovering+0x41
2015-07-30T16:07:22.181-0300 I CONTROL  [initandlisten] mongod.exe    ...\src\mongo\db\index\expression_keys_private.cpp(82)          `anonymous namespace'::S2KeysFromRegion+0x3e
2015-07-30T16:07:22.181-0300 I CONTROL  [initandlisten] mongod.exe    ...\src\mongo\db\index\expression_keys_private.cpp(122)         `anonymous namespace'::S2GetKeysForElement+0x367
2015-07-30T16:07:22.181-0300 I CONTROL  [initandlisten] mongod.exe    ...\src\mongo\db\index\expression_keys_private.cpp(135)         `anonymous namespace'::getS2GeoKeys+0x91
2015-07-30T16:07:22.181-0300 I CONTROL  [initandlisten] mongod.exe    ...\src\mongo\db\index\expression_keys_private.cpp(472)         mongo::ExpressionKeysPrivate::getS2Keys+0x337
2015-07-30T16:07:22.181-0300 I CONTROL  [initandlisten] mongod.exe    ...\src\mongo\db\index\btree_based_bulk_access_method.cpp(106)  mongo::BtreeBasedBulkAccessMethod::insert+0x7a
2015-07-30T16:07:22.181-0300 I CONTROL  [initandlisten] mongod.exe    ...\src\mongo\db\catalog\index_create.cpp(336)                  mongo::MultiIndexBlock::insert+0x145
2015-07-30T16:07:22.181-0300 I CONTROL  [initandlisten] mongod.exe    ...\src\mongo\db\catalog\index_create.cpp(269)                  mongo::MultiIndexBlock::insertAllDocumentsInCollection+0x594
2015-07-30T16:07:22.181-0300 I CONTROL  [initandlisten] mongod.exe    ...\src\mongo\db\index_rebuilder.cpp(127)                       mongo::`anonymous namespace'::checkNS+0x6c6
2015-07-30T16:07:22.181-0300 I CONTROL  [initandlisten] mongod.exe    ...\src\mongo\db\index_rebuilder.cpp(171)                       mongo::restartInProgressIndexesFromLastShutdown+0x155
2015-07-30T16:07:22.182-0300 I CONTROL  [initandlisten] mongod.exe    ...\src\mongo\db\db.cpp(612)                                    mongo::_initAndListen+0x10da
2015-07-30T16:07:22.182-0300 I CONTROL  [initandlisten] mongod.exe    ...\src\mongo\db\db.cpp(651)                                    mongo::initAndListen+0x27
2015-07-30T16:07:22.182-0300 I CONTROL  [initandlisten] mongod.exe    ...\src\mongo\db\db.cpp(896)                                    mongoDbMain+0x1fe
2015-07-30T16:07:22.182-0300 I CONTROL  [initandlisten] mongod.exe    ...\src\mongo\db\db.cpp(694)                                    wmain+0x35
2015-07-30T16:07:22.182-0300 I CONTROL  [initandlisten] mongod.exe    f:\dd\vctools\crt\crtw32\startup\crt0.c(255)                    __tmainCRTStartup+0x144
2015-07-30T16:07:22.182-0300 I CONTROL  [initandlisten] kernel32.dll                                                                  BaseThreadInitThunk+0xd
2015-07-30T16:07:22.182-0300 I CONTROL  [initandlisten] 
2015-07-30T16:07:22.182-0300 I -        [initandlisten] 



 Comments   
Comment by Githook User [ 17/Feb/21 ]

Author:

{'name': 'Bynn Lee', 'email': 'bynn.lee@mongodb.com', 'username': 'bynn'}

Message: SERVER-44194 Complete TODO listed in SERVER-19674
Branch: master
https://github.com/mongodb/mongo/commit/9a6db0855a38a1bb6d3ec5c92c145b48de5e2576

Comment by Kevin Albertson [ 14/Aug/15 ]

This error has been changed to a warning as a workaround. SERVER-19913 has been created to solve the more general problem of fatal assertions potentially being triggered in S2 from numerical error.

Comment by Githook User [ 14/Aug/15 ]

Author:

{u'username': u'kevinAlbs', u'name': u'Kevin Albertson', u'email': u'kevin.albertson@10gen.com'}

Message: SERVER-19674 Change S2 fatal error to warning
Branch: master
https://github.com/mongodb/mongo/commit/a925e2622bd55b852a52b3a9afd1b0cf0f01116c

Comment by Eric Milkie [ 07/Aug/15 ]

I don't think we have mpfloat.h anywhere so enabling the flag probably won't work, unfortunately.
We may have to come up with a way of avoiding the issue by changing the code.

Comment by Kevin Albertson [ 06/Aug/15 ]

This seems to stem from two issues.

Points may be represented slightly differently in Windows when converted from lat/lon representation (https://github.com/mongodb/mongo/blob/master/src/third_party/s2/s2latlng.cc#L25-L28).

However, the difference is very small. This alone is not the sole reason of the fassert failure. If you substitute the exact representation of the points from the Windows failure in OSX, the same fassert can be triggered. This can be reproduced with this unit test https://gist.github.com/kevinAlbs/ef86dc8805580c52ab64

Based on this comment https://github.com/mongodb/mongo/blob/master/src/third_party/s2/s2.cc#L171-L178, it seems that the default ExpensiveCCW has some degenerate cases where it will incorrectly return 0. S2 holds the assumption that ExpensiveCCW will return 0 iff two points are exactly equal, which is not true for a set of points in this case. This is what leads to the later fassert failure. I'm going to try enabling the S2_USE_EXACTFLOAT flag to see if the other version of ExpensiveCCW resolves this issue.

Comment by Humberto [ 30/Jul/15 ]

Got the same error on Windows 7 Professional 64 bits. Something related to longitude -45.0000 that crashes (I guess) the mongod server while trying to create a 2dsphere index.

Generated at Thu Feb 08 03:51:43 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.