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

CRUD operation fails: cannot update arrays using $set

    XMLWordPrintable

    Details

      Description

      Certain updated constellations either fail and/or crash the server.

      // EXAMPLE DOC //

      _id : 7      5106887fe2be1937c1e3c8b0
      host : 2     host1.com
      array : 4    
          0 : 2    value1
          1 : 2    value2
          2 : 2    value3

      // EXAMPLE OF UPDATE THAT FAILS //

      b <- mongo.bson.from.list(list(
          host="host1.com",
          array="value1"
      ))
      b
      mongo.find.one(mongo=con, ns="mytest.hosts", query=b)
      value.new <- "othervalue"
      bnew <- mongo.bson.from.list(list(
          "$set"=list("array.$"=value.new)
      ))
      res <- mongo.update(mongo=con, ns=ns, criteria=b, objNew=bnew)

      // EXCERPT OF ERROR LOG //

      Mon Jan 28 15:19:37 [conn1]  mytest.hosts Assertion failure x == _nfields src\mongo\db\jsobj.cpp 1250
      Mon Jan 28 15:19:37 [conn1] mongod.exe    ...\src\mongo\util\stacktrace.cpp(182)                           mongo::printStackTrace+0x3e
      Mon Jan 28 15:19:37 [conn1] mongod.exe    ...\src\mongo\util\assert_util.cpp(109)                          mongo::verifyFailed+0xdc
      Mon Jan 28 15:19:37 [conn1] mongod.exe    ...\src\mongo\db\jsobj.cpp(1250)                                 mongo::BSONIteratorSorted::BSONIteratorSorted+0xf3
      Mon Jan 28 15:19:37 [conn1] mongod.exe    ...\src\mongo\db\ops\update_internal.cpp(906)                    mongo::ModSetState::createNewFromMods+0xa3
      Mon Jan 28 15:19:37 [conn1] mongod.exe    ...\src\mongo\db\ops\update.cpp(370)                             mongo::_updateObjects+0x15a2
      Mon Jan 28 15:19:37 [conn1] mongod.exe    ...\src\mongo\db\instance.cpp(573)                               mongo::receivedUpdate+0x60d
      Mon Jan 28 15:19:37 [conn1] mongod.exe    ...\src\mongo\db\instance.cpp(437)                               mongo::assembleResponse+0x626
      Mon Jan 28 15:19:37 [conn1] mongod.exe    ...\src\mongo\db\db.cpp(193)                                     mongo::MyMessageHandler::process+0xf5
      Mon Jan 28 15:19:37 [conn1] mongod.exe    ...\src\mongo\util\net\message_server_port.cpp(86)               mongo::pms::threadRun+0x59a
      Mon Jan 28 15:19:37 [conn1] mongod.exe    ...\src\third_party\boost\libs\thread\src\win32\thread.cpp(180)  boost::`anonymous namespace'::thread_start_function+0x21
      Mon Jan 28 15:19:37 [conn1] mongod.exe    f:\dd\vctools\crt_bld\self_64_amd64\crt\src\threadex.c(314)      _callthreadstartex+0x17
      Mon Jan 28 15:19:37 [conn1] mongod.exe    f:\dd\vctools\crt_bld\self_64_amd64\crt\src\threadex.c(292)      _threadstartex+0x7f
      Mon Jan 28 15:19:37 [conn1] kernel32.dll                                                                   BaseThreadInitThunk+0xd
      Mon Jan 28 15:19:37 [conn1] update mytest.hosts query: { host: "host1.com", array: "VALUE1" } update: { $set: { array.$: "othervalue" } } nscanned:1 keyUpdates:0 exception: assertion src\mongo\db\jsobj.cpp:1250 locks(micros) w:343875 344ms
      Mon Jan 28 15:20:06 [conn1]  mytest.hosts Assertion failure x == _nfields src\mongo\db\jsobj.cpp 1250
      Mon Jan 28 15:20:06 [conn1] mongod.exe    ...\src\mongo\util\stacktrace.cpp(182)                           mongo::printStackTrace+0x3e
      Mon Jan 28 15:20:06 [conn1] mongod.exe    ...\src\mongo\util\assert_util.cpp(109)                          mongo::verifyFailed+0xdc
      Mon Jan 28 15:20:06 [conn1] mongod.exe    ...\src\mongo\db\jsobj.cpp(1250)                                 mongo::BSONIteratorSorted::BSONIteratorSorted+0xf3
      Mon Jan 28 15:20:06 [conn1] mongod.exe    ...\src\mongo\db\ops\update_internal.cpp(906)                    mongo::ModSetState::createNewFromMods+0xa3
      Mon Jan 28 15:20:06 [conn1] mongod.exe    ...\src\mongo\db\ops\update.cpp(370)                             mongo::_updateObjects+0x15a2
      Mon Jan 28 15:20:06 [conn1] mongod.exe    ...\src\mongo\db\instance.cpp(573)                               mongo::receivedUpdate+0x60d
      Mon Jan 28 15:20:06 [conn1] mongod.exe    ...\src\mongo\db\instance.cpp(437)                               mongo::assembleResponse+0x626
      Mon Jan 28 15:20:06 [conn1] mongod.exe    ...\src\mongo\db\db.cpp(193)                                     mongo::MyMessageHandler::process+0xf5
      Mon Jan 28 15:20:06 [conn1] mongod.exe    ...\src\mongo\util\net\message_server_port.cpp(86)               mongo::pms::threadRun+0x59a
      Mon Jan 28 15:20:06 [conn1] mongod.exe    ...\src\third_party\boost\libs\thread\src\win32\thread.cpp(180)  boost::`anonymous namespace'::thread_start_function+0x21
      Mon Jan 28 15:20:06 [conn1] mongod.exe    f:\dd\vctools\crt_bld\self_64_amd64\crt\src\threadex.c(314)      _callthreadstartex+0x17
      Mon Jan 28 15:20:06 [conn1] mongod.exe    f:\dd\vctools\crt_bld\self_64_amd64\crt\src\threadex.c(292)      _threadstartex+0x7f
      Mon Jan 28 15:20:06 [conn1] kernel32.dll                                                                   BaseThreadInitThunk+0xd
      Mon Jan 28 15:20:06 [conn1] update mytest.hosts query: { host: "host1.com", array: "value2" } update: { $set: { array.0: "abcd" } } nscanned:1 keyUpdates:0 exception: assertion src\mongo\db\jsobj.cpp:1250 locks(micros) w:344363 345ms
      Mon Jan 28 15:20:06 [journal] *** unhandled exception (access violation) at 0x0000000076D632D0, terminating
      Mon Jan 28 15:20:06 [journal] *** access violation was a read from 0x0000008301570AD8
      Mon Jan 28 15:20:06 [journal] *** stack trace for unhandled exception:
      Mon Jan 28 15:20:06 [journal] ntdll.dll                                                                      RtlFreeHeap+0xd0
      Mon Jan 28 15:20:06 [journal] kernel32.dll                                                                   HeapFree+0xa
      Mon Jan 28 15:20:06 [journal] mongod.exe    f:\dd\vctools\crt_bld\self_64_amd64\crt\src\free.c(51)           free+0x1c
      Mon Jan 28 15:20:06 [journal] mongod.exe    ...\src\mongo\db\d_concurrency.cpp(309)                          mongo::Lock::ScopedLock::~ScopedLock+0xac
      Mon Jan 28 15:20:06 [journal] mongod.exe                                                                     mongo::Lock::GlobalRead::`scalar deleting destructor'+0x14
      Mon Jan 28 15:20:06 [journal] mongod.exe    ...\src\mongo\db\dur.cpp(567)                                    mongo::dur::_groupCommitWithLimitedLocks+0x174
      Mon Jan 28 15:20:06 [journal] mongod.exe    ...\src\mongo\db\dur.cpp(608)                                    mongo::dur::groupCommitWithLimitedLocks+0x24
      Mon Jan 28 15:20:06 [journal] mongod.exe    ...\src\mongo\db\dur.cpp(743)                                    mongo::dur::durThreadGroupCommit+0x70
      Mon Jan 28 15:20:06 [journal] mongod.exe    ...\src\mongo\db\dur.cpp(814)                                    mongo::dur::durThread+0x198
      Mon Jan 28 15:20:06 [journal] mongod.exe    ...\src\third_party\boost\libs\thread\src\win32\thread.cpp(180)  boost::`anonymous namespace'::thread_start_function+0x21
      Mon Jan 28 15:20:06 [journal] mongod.exe    f:\dd\vctools\crt_bld\self_64_amd64\crt\src\threadex.c(314)      _callthreadstartex+0x17
      Mon Jan 28 15:20:06 [journal] mongod.exe    f:\dd\vctools\crt_bld\self_64_amd64\crt\src\threadex.c(292)      _threadstartex+0x7f
      Mon Jan 28 15:20:06 [journal] kernel32.dll                                                                   BaseThreadInitThunk+0xd
      Mon Jan 28 15:20:06 [journal] writing minidump diagnostic file mongo.dmp
      Mon Jan 28 15:20:06 [journal] *** immediate exit due to unhandled exception

      For a fully reproducible example see here: http://stackoverflow.com/questions/14564613/updating-arrays-with-the-set-operator-in-mongodb-rmongodb

        Attachments

          Activity

            People

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

              Dates

              • Created:
                Updated:
                Resolved: