Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-13409

$near query trips verify when both 2d and 2dsphere indexes exist on same field

    • Type: Icon: Bug Bug
    • Resolution: Duplicate
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 2.6.0-rc2
    • Component/s: None
    • Labels:
      None
    • ALL

      If a user has an index {loc:"2d"} and {loc:"2dsphere"} on the same collection, then $near queries will trip the "!indexIs2d" verify() assertion failure.

      Note that the documentation specifies "MongoDB allows only one geospatial index per collection. You can create either a 2dsphere or a 2d per collection", so to reproduce this the user technically had to break the rules.

      > db.version()
      2.6.0-rc2
      > db.foo.ensureIndex({loc:"2d"})
      WriteResult({ "nInserted" : 1 })
      > db.foo.ensureIndex({loc:"2dsphere"})
      WriteResult({ "nInserted" : 1 })
      > db.foo.find({loc:{$near:{$geometry:{type: "Point", coordinates:[10,10]}}}})
      error: { "$err" : "assertion src/mongo/db/query/planner_access.cpp:116" }
      

      In 2.4.9, the query succeeds:

      > db.version()
      2.4.9
      > db.foo.find({loc:{$near:{$geometry:{type: "Point", coordinates:[10,10]}}}})
      { "_id" : ObjectId("5338bc829a4bea067ac904fa"), "loc" : [ 10, 10 ] }
      

      Log output for the assertion failure:

      2014-03-30T20:57:06.700-0400 [conn1] test.foo Assertion failure !indexIs2D src/mongo/db/query/planner_access.cpp 116
      2014-03-30T20:57:06.705-0400 [conn1] test.foo 0x100698b8b 0x100651542 0x100641fc2 0x1003de934 0x1003e03e2 0x1003ef6b4 0x1003a7f47 0x1003a9d9e 0x1003aa8ce 0x1003c4427 0x100298c40 0x1000069e4 0x10065ecf1 0x1006ccf95 0x101ce8782 0x101cd51c1
       0   mongod260rc2                        0x0000000100698b8b _ZN5mongo15printStackTraceERSo + 43
       1   mongod260rc2                        0x0000000100651542 _ZN5mongo10logContextEPKc + 114
       2   mongod260rc2                        0x0000000100641fc2 _ZN5mongo12verifyFailedEPKcS1_j + 274
       3   mongod260rc2                        0x00000001003de934 _ZN5mongo18QueryPlannerAccess12makeLeafNodeERKNS_14CanonicalQueryERKNS_10IndexEntryEmPNS_15MatchExpressionEPNS_18IndexBoundsBuilder15BoundsTightnessE + 188
       4   mongod260rc2                        0x00000001003e03e2 _ZN5mongo18QueryPlannerAccess22buildIndexedDataAccessERKNS_14CanonicalQueryEPNS_15MatchExpressionEbRKSt6vectorINS_10IndexEntryESaIS7_EE + 342
       5   mongod260rc2                        0x00000001003ef6b4 _ZN5mongo12QueryPlanner4planERKNS_14CanonicalQueryERKNS_18QueryPlannerParamsEPSt6vectorIPNS_13QuerySolutionESaIS9_EE + 10762
       6   mongod260rc2                        0x00000001003a7f47 _ZN5mongo19getRunnerAlwaysPlanEPNS_10CollectionEPNS_14CanonicalQueryERKNS_18QueryPlannerParamsEPPNS_6RunnerE + 119
       7   mongod260rc2                        0x00000001003a9d9e _ZN5mongo9getRunnerEPNS_10CollectionEPNS_14CanonicalQueryEPPNS_6RunnerEm + 1790
       8   mongod260rc2                        0x00000001003aa8ce _ZN5mongo9getRunnerEPNS_14CanonicalQueryEPPNS_6RunnerEm + 158
       9   mongod260rc2                        0x00000001003c4427 _ZN5mongo11newRunQueryERNS_7MessageERNS_12QueryMessageERNS_5CurOpES1_ + 3847
       10  mongod260rc2                        0x0000000100298c40 _ZN5mongo16assembleResponseERNS_7MessageERNS_10DbResponseERKNS_11HostAndPortE + 1968
       11  mongod260rc2                        0x00000001000069e4 _ZN5mongo16MyMessageHandler7processERNS_7MessageEPNS_21AbstractMessagingPortEPNS_9LastErrorE + 308
       12  mongod260rc2                        0x000000010065ecf1 _ZN5mongo17PortMessageServer17handleIncomingMsgEPv + 1681
       13  mongod260rc2                        0x00000001006ccf95 thread_proxy + 229
       14  libsystem_c.dylib                   0x0000000101ce8782 _pthread_start + 327
       15  libsystem_c.dylib                   0x0000000101cd51c1 thread_start + 13
      2014-03-30T20:57:06.708-0400 [conn1] assertion 0 assertion src/mongo/db/query/planner_access.cpp:116 ns:test.foo query:{ loc: { $near: { $geometry: { type: "Point", coordinates: [ 10.0, 10.0 ] } } } }
      

            Assignee:
            david.storch@mongodb.com David Storch
            Reporter:
            rassi J Rassi
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: