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

The geoNear command can create too large BSON objects

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Fixed
    • Affects Version/s: 2.6.0-rc1, 2.6.0-rc2
    • Fix Version/s: 2.6.1, 2.7.0
    • Component/s: Aggregation Framework
    • Labels:
      None
    • Operating System:
      ALL
    • Backport Completed:
    • Steps To Reproduce:
      Hide

      for (var i = 1; i <= 200000; i++) db.testData.insert( { loc :

      {type:"Point", coordinates:[90*(i/200000),90*(i/200000)]}

      } )

      db.testData.ensureIndex(

      {loc : "2dsphere"}

      )

      db.testData.aggregate([{$geoNear: {near :

      { type : "Point" , coordinates: [50,50] }

      , distanceField:"dist",spherical : true, maxDistance : (10000000), num:200000 }}])

      Show
      for (var i = 1; i <= 200000; i++) db.testData.insert( { loc : {type:"Point", coordinates:[90*(i/200000),90*(i/200000)]} } ) db.testData.ensureIndex( {loc : "2dsphere"} ) db.testData.aggregate([{$geoNear: {near : { type : "Point" , coordinates: [50,50] } , distanceField:"dist",spherical : true, maxDistance : (10000000), num:200000 }}])

      Description

      Issue Status as of April 15, 2014

      ISSUE SUMMARY
      The geoNear command does not check if the BSON size limit is reached when assembling the result array.

      USER IMPACT
      Results from geoNear that are larger than the BSON size (16MB) cause an exception and abort the command.

      WORKAROUNDS
      Query for a smaller result set, for example with a smaller maxDistance value.

      RESOLUTION
      The geoNear command now detects when it reaches the BSON size and will truncate the result set. A warning is logged that the command tried to return a larger result.

      AFFECTED VERSIONS
      Version 2.6.0 is affected by this bug.

      PATCHES
      The patch is included in the 2.6.1 production release.

      Original description

      The new aggregation framework on 2.6.0 returns a cursor, so its output should be unlimited.
      However if one performs an aggregation query with $geonear it looks like the output is still limited to 16MB.

      > db.testData.aggregate([{$geoNear: {near :

      { type : "Point" , coordinates: [50,50] }

      , distanceField:"dist",spherical : true, maxDistance : (10000000), num:200000 }}])
      assert: command failed: {
      "errmsg" : "exception: nextSafe():

      { $err: \"BSONObj size: 23689189 (0x16977E5) is invalid. Size must be between 0 and 16793600(16MB)\", code: 10334 }

      ",
      "code" : 13106,
      "ok" : 0
      } : aggregate failed
      Error: command failed: {
      "errmsg" : "exception: nextSafe():

      { $err: \"BSONObj size: 23689189 (0x16977E5) is invalid. Size must be between 0 and 16793600(16MB)\", code: 10334 }

      ",
      "code" : 13106,
      "ok" : 0
      } : aggregate failed
      at Error (<anonymous>)
      at doassert (src/mongo/shell/assert.js:11:14)
      at Function.assert.commandWorked (src/mongo/shell/assert.js:244:5)
      at DBCollection.aggregate (src/mongo/shell/collection.js:1149:12)
      at (shell):1:13
      2014-04-04T11:17:26.395+0200 Error: command failed: {
      "errmsg" : "exception: nextSafe():

      { $err: \"BSONObj size: 23689189 (0x16977E5) is invalid. Size must be between 0 and 16793600(16MB)\", code: 10334 }

      ",
      "code" : 13106,
      "ok" : 0
      } : aggregate failed at src/mongo/shell/assert.js:13

        Attachments

          Activity

            People

            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: