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

group command triggers assertion failure when CodeWScope type given for $reduce arg

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 2.7.7
    • Component/s: JavaScript, MapReduce, Querying
    • Labels:
      None
    • Operating System:
      ALL
    • Steps To Reproduce:
      Hide

      Sadly the mongo shell doesn't support code_w_scope so the best I can do is provide python:

      >>> c = pymongo.MongoClient()
      >>> from bson.code import Code
      >>> reduce_function = "function (obj, prev) { prev.count += inc_value; }"
      >>> db = c.test
      >>> db.test.drop()
      >>> db.test.insert({'a': 1})
      ObjectId('541365f7fba52245c1cac975')
      >>> db.test.insert({'a': 2})
      ObjectId('541365f9fba52245c1cac976')
      >>> db.test.group([], {}, {"count": 0}, Code(reduce_function, {"inc_value": 1}))
      Traceback (most recent call last):
        File "<stdin>", line 1, in <module>
        File "pymongo/collection.py", line 1412, in group
          **kwargs)["retval"]
        File "pymongo/database.py", line 434, in command
          read_preference, **kwargs)[0]
        File "pymongo/database.py", line 349, in _command
          msg, allowable_errors)
        File "pymongo/helpers.py", line 180, in _check_command_response
          raise OperationFailure(msg % errmsg, code, response)
      pymongo.errors.OperationFailure: command SON([(u'group', {u'$reduce': Code('function (obj, prev) { prev.count += inc_value; }', {'inc_value': 1}), u'ns': u'test', u'cond': {}, u'key': {}, u'initial': {'count': 0}})]) failed: exception: BSONObj size: 1953693716 (0x74730014) is invalid. Size must be between 0 and 16793600(16MB) First element: EOO

      Show
      Sadly the mongo shell doesn't support code_w_scope so the best I can do is provide python: >>> c = pymongo.MongoClient() >>> from bson.code import Code >>> reduce_function = "function (obj, prev) { prev.count += inc_value; }" >>> db = c.test >>> db.test.drop() >>> db.test.insert({'a': 1}) ObjectId('541365f7fba52245c1cac975') >>> db.test.insert({'a': 2}) ObjectId('541365f9fba52245c1cac976') >>> db.test.group([], {}, {"count": 0}, Code(reduce_function, {"inc_value": 1})) Traceback (most recent call last): File "<stdin>", line 1, in <module> File "pymongo/collection.py", line 1412, in group **kwargs)["retval"] File "pymongo/database.py", line 434, in command read_preference, **kwargs)[0] File "pymongo/database.py", line 349, in _command msg, allowable_errors) File "pymongo/helpers.py", line 180, in _check_command_response raise OperationFailure(msg % errmsg, code, response) pymongo.errors.OperationFailure: command SON([(u'group', {u'$reduce': Code('function (obj, prev) { prev.count += inc_value; }', {'inc_value': 1}), u'ns': u'test', u'cond': {}, u'key': {}, u'initial': {'count': 0}})]) failed: exception: BSONObj size: 1953693716 (0x74730014) is invalid. Size must be between 0 and 16793600(16MB) First element: EOO

      Description

      This seems to be a new failure in the latest nightly:

      2014-09-12T14:15:46.026-0700 I -        [initandlisten] db version v2.7.7-pre-
      2014-09-12T14:15:46.026-0700 I -        [initandlisten] git version: e079496c239748c95136458c85c23478ee609fdb modules: subscription

      Log backtrace:

      2014-09-12T14:23:10.649-0700 I -        [conn4] Assertion: 10334:BSONObj size: 1953693716 (0x74730014) is invalid. Size must be between 0 and 16793600(16MB) First element: EOO
      2014-09-12T14:23:10.658-0700 I -        [conn4] 
       0xfc99a3 0xf72d4b 0xf594ca 0xf5956c 0x910186 0xaa1a98 0xac37d3 0xcb11dd 0xa2dc5e 0xa929a2 0xa9347d 0xa93d83 0xc9d21f 0xb6761b 0x8e6280 0xf84ffb 0x7f1740c4c1da 0x7f173fff3d7d
      ----- BEGIN BACKTRACE -----
      {"backtrace":[{"b":"400000","o":"BC99A3"},{"b":"400000","o":"B72D4B"},{"b":"400000","o":"B594CA"},{"b":"400000","o":"B5956C"},{"b":"400000","o":"510186"},{"b":"400000","o":"6A1A98"},{"b":"400000","o":"6C37D3"},{"b":"400000","o":"8B11DD"},{"b":"400000","o":"62DC5E"},{"b":"400000","o":"6929A2"},{"b":"400000","o":"69347D"},{"b":"400000","o":"693D83"},{"b":"400000","o":"89D21F"},{"b":"400000","o":"76761B"},{"b":"400000","o":"4E6280"},{"b":"400000","o":"B84FFB"},{"b":"7F1740C43000","o":"91DA"},{"b":"7F173FF06000","o":"EDD7D"}],"processInfo":{ "mongodbVersion" : "2.7.7-pre-", "gitVersion" : "e079496c239748c95136458c85c23478ee609fdb modules: subscription", "uname" : { "sysname" : "Linux", "release" : "3.14.14-gentoo", "version" : "#1 SMP PREEMPT Fri Aug 1 15:52:24 PDT 2014", "machine" : "x86_64" }, "somap" : [ { "elfType" : 2, "b" : "400000" }, { "b" : "7FFFC68BA000", "path" : "linux-vdso.so.1", "elfType" : 3 }, { "b" : "7F174255E000", "path" : "/usr/lib64/libsasl2.so.3", "elfType" : 3 }, { "b" : "7F17420DF000", "path" : "/usr/lib64/libnetsnmpmibs.so.30", "elfType" : 3 }, { "b" : "7F1741EDB000", "path" : "/lib64/libdl.so.2", "elfType" : 3 }, { "b" : "7F1741C6D000", "path" : "/usr/lib64/libnetsnmpagent.so.30", "elfType" : 3 }, { "b" : "7F1741A63000", "path" : "/lib64/libwrap.so.0", "elfType" : 3 }, { "b" : "7F1741782000", "path" : "/usr/lib64/libnetsnmp.so.30", "elfType" : 3 }, { "b" : "7F17413AC000", "path" : "/usr/lib64/libcrypto.so.1.0.0", "elfType" : 3 }, { "b" : "7F1741163000", "path" : "/usr/lib64/libgssapi_krb5.so.2", "elfType" : 3 }, { "b" : "7F1740E61000", "path" : "/lib64/libm.so.6", "elfType" : 3 }, { "b" : "7F1740C43000", "path" : "/lib64/libpthread.so.0", "elfType" : 3 }, { "b" : "7F17409D2000", "path" : "/usr/lib64/libssl.so.1.0.0", "elfType" : 3 }, { "b" : "7F17407CA000", "path" : "/lib64/librt.so.1", "elfType" : 3 }, { "b" : "7F17404C3000", "path" : "/usr/lib/gcc/x86_64-pc-linux-gnu/4.7.3/libstdc++.so.6", "elfType" : 3 }, { "b" : "7F17402AD000", "path" : "/usr/lib/gcc/x86_64-pc-linux-gnu/4.7.3/libgcc_s.so.1", "elfType" : 3 }, { "b" : "7F173FF06000", "path" : "/lib64/libc.so.6", "elfType" : 3 }, { "b" : "7F174277B000", "path" : "/lib64/ld-linux-x86-64.so.2", "elfType" : 3 }, { "b" : "7F173FCF0000", "path" : "/lib64/libz.so.1", "elfType" : 3 }, { "b" : "7F173FA1E000", "path" : "/usr/lib64/libkrb5.so.3", "elfType" : 3 }, { "b" : "7F173F7ED000", "path" : "/usr/lib64/libk5crypto.so.3", "elfType" : 3 }, { "b" : "7F173F5E9000", "path" : "/lib64/libcom_err.so.2", "elfType" : 3 }, { "b" : "7F173F3DD000", "path" : "/usr/lib64/libkrb5support.so.0", "elfType" : 3 }, { "b" : "7F173F1D9000", "path" : "/lib64/libkeyutils.so.1", "elfType" : 3 }, { "b" : "7F173EFC2000", "path" : "/lib64/libresolv.so.2", "elfType" : 3 }, { "b" : "7F173EBF8000", "path" : "/usr/lib64/sasl2/liblogin.so", "elfType" : 3 }, { "b" : "7F173E9F1000", "path" : "/usr/lib64/sasl2/libsasldb.so", "elfType" : 3 }, { "b" : "7F173E7E5000", "path" : "/usr/lib64/libgdbm.so.4", "elfType" : 3 }, { "b" : "7F173E5E0000", "path" : "/usr/lib64/sasl2/libanonymous.so", "elfType" : 3 }, { "b" : "7F173E3DA000", "path" : "/usr/lib64/sasl2/libcrammd5.so", "elfType" : 3 }, { "b" : "7F173E1D1000", "path" : "/usr/lib64/sasl2/libntlm.so", "elfType" : 3 }, { "b" : "7F173DFCA000", "path" : "/usr/lib64/sasl2/libsql.so", "elfType" : 3 }, { "b" : "7F173DD0C000", "path" : "/usr/lib64/libsqlite3.so.0", "elfType" : 3 }, { "b" : "7F173D8FE000", "path" : "/usr/lib64/libicui18n.so.52", "elfType" : 3 }, { "b" : "7F173D585000", "path" : "/usr/lib64/libicuuc.so.52", "elfType" : 3 }, { "b" : "7F173BD18000", "path" : "/usr/lib64/libicudata.so.52", "elfType" : 3 }, { "b" : "7F173BB0E000", "path" : "/usr/lib64/sasl2/libscram.so", "elfType" : 3 }, { "b" : "7F173B900000", "path" : "/usr/lib64/sasl2/libdigestmd5.so", "elfType" : 3 }, { "b" : "7F173B6F7000", "path" : "/usr/lib64/sasl2/libgs2.so", "elfType" : 3 }, { "b" : "7F173B4F2000", "path" : "/usr/lib64/sasl2/libplain.so", "elfType" : 3 }, { "b" : "7F173B2D8000", "path" : "/usr/lib64/sasl2/libotp.so", "elfType" : 3 }, { "b" : "7F173B0CF000", "path" : "/usr/lib64/sasl2/libgssapiv2.so", "elfType" : 3 } ] }}
       mongod(_ZN5mongo15printStackTraceERSo+0x23) [0xfc99a3]
       mongod(_ZN5mongo10logContextEPKc+0xDB) [0xf72d4b]
       mongod(_ZN5mongo11msgassertedEiPKc+0x7A) [0xf594ca]
       mongod(+0xB5956C) [0xf5956c]
       mongod(_ZNK5mongo7BSONObj14_assertInvalidEv+0x416) [0x910186]
       mongod(_ZN5mongo5Scope4initEPKc+0x68) [0xaa1a98]
       mongod(_ZN5mongo10GroupStage4workEPm+0x903) [0xac37d3]
       mongod(_ZN5mongo12PlanExecutor7getNextEPNS_7BSONObjEPNS_7DiskLocE+0x5D) [0xcb11dd]
       mongod(_ZN5mongo12GroupCommand3runEPNS_16OperationContextERKSsRNS_7BSONObjEiRSsRNS_14BSONObjBuilderEb+0x19E) [0xa2dc5e]
       mongod(_ZN5mongo12_execCommandEPNS_16OperationContextEPNS_7CommandERKSsRNS_7BSONObjEiRSsRNS_14BSONObjBuilderEb+0x42) [0xa929a2]
       mongod(_ZN5mongo7Command11execCommandEPNS_16OperationContextEPS0_iPKcRNS_7BSONObjERNS_14BSONObjBuilderEb+0x8DD) [0xa9347d]
       mongod(_ZN5mongo12_runCommandsEPNS_16OperationContextEPKcRNS_7BSONObjERNS_11_BufBuilderINS_16TrivialAllocatorEEERNS_14BSONObjBuilderEbi+0x4C3) [0xa93d83]
       mongod(_ZN5mongo11newRunQueryEPNS_16OperationContextERNS_7MessageERNS_12QueryMessageERNS_5CurOpES3_+0x1CF) [0xc9d21f]
       mongod(_ZN5mongo16assembleResponseEPNS_16OperationContextERNS_7MessageERNS_10DbResponseERKNS_11HostAndPortE+0xABB) [0xb6761b]
       mongod(_ZN5mongo16MyMessageHandler7processERNS_7MessageEPNS_21AbstractMessagingPortEPNS_9LastErrorE+0xA0) [0x8e6280]
       mongod(_ZN5mongo17PortMessageServer17handleIncomingMsgEPv+0x47B) [0xf84ffb]
       libpthread.so.0(+0x91DA) [0x7f1740c4c1da]
       libc.so.6(clone+0x6D) [0x7f173fff3d7d]
      -----  END BACKTRACE  -----

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              rassi J Rassi
              Reporter:
              behackett Bernie Hackett
              Participants:
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: