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

MongoDB query using the $or operator with 54 expressions crashes mongod

    XMLWordPrintableJSON

Details

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: Major - P3 Major - P3
    • None
    • 1.6.5
    • None
    • None
    • Crunchbang Linux 9.04
    • Linux

    Description

      I have a database containing 230218 documents. Each document represents a request to a web application, parsed into the database from an Apache log. Each search comes from a particular ip address, which is represented in the document by a field named "ip_as_int". The query I am trying to run on the database asks for all searches coming from within 54 ip ranges. The form of the query is as follows, substituting for the ip_as_int values for privacy:

      db.search_views.find({$or: [{ip_as_int:{$gte:foo00, $lte:bar00}}, {ip_as_int:{$gte:foo01, $lte:bar01}}, {ip_as_int:{$gte:foo02, $lte:bar02}}, {ip_as_int:{$gte:foo03, $lte:bar03}}, {ip_as_int:{$gte:foo04, $lte:bar04}}, {ip_as_int:{$gte:foo05, $lte:bar05}}, {ip_as_int:{$gte:foo06, $lte:bar06}}, {ip_as_int:{$gte:foo07, $lte:bar07}}, {ip_as_int:{$gte:foo08, $lte:bar08}}, {ip_as_int:{$gte:foo09, $lte:bar09}}, {ip_as_int:{$gte:foo10, $lte:bar10}}, {ip_as_int:{$gte:foo11, $lte:bar11}}, {ip_as_int:{$gte:foo12, $lte:bar12}}, {ip_as_int:{$gte:foo13, $lte:bar13}}, {ip_as_int:{$gte:foo14, $lte:bar14}}, {ip_as_int:{$gte:foo15, $lte:bar15}}, {ip_as_int:{$gte:foo16, $lte:bar16}}, {ip_as_int:{$gte:foo17, $lte:bar17}}, {ip_as_int:{$gte:foo18, $lte:bar18}}, {ip_as_int:{$gte:foo19, $lte:bar19}}, {ip_as_int:{$gte:foo20, $lte:bar20}}, {ip_as_int:{$gte:foo21, $lte:bar21}}, {ip_as_int:{$gte:foo22, $lte:bar22}}, {ip_as_int:{$gte:foo23, $lte:bar23}}, {ip_as_int:{$gte:foo24, $lte:bar24}}, {ip_as_int:{$gte:foo25, $lte:bar25}}, {ip_as_int:{$gte:foo26, $lte:bar26}}, {ip_as_int:{$gte:foo27, $lte:bar27}}, {ip_as_int:{$gte:foo28, $lte:bar28}}, {ip_as_int:{$gte:foo29, $lte:bar29}}, {ip_as_int:{$gte:foo30, $lte:bar30}}, {ip_as_int:{$gte:foo31, $lte:bar31}}, {ip_as_int:{$gte:foo32, $lte:bar32}}, {ip_as_int:{$gte:foo33, $lte:bar33}}, {ip_as_int:{$gte:foo34, $lte:bar34}}, {ip_as_int:{$gte:foo35, $lte:bar35}}, {ip_as_int:{$gte:foo36, $lte:bar36}}, {ip_as_int:{$gte:foo37, $lte:bar37}}, {ip_as_int:{$gte:foo38, $lte:bar38}}, {ip_as_int:{$gte:foo39, $lte:bar39}}, {ip_as_int:{$gte:foo40, $lte:bar40}}, {ip_as_int:{$gte:foo41, $lte:bar41}}, {ip_as_int:{$gte:foo42, $lte:bar42}}, {ip_as_int:{$gte:foo43, $lte:bar43}}, {ip_as_int:{$gte:foo44, $lte:bar44}}, {ip_as_int:{$gte:foo45, $lte:bar45}}, {ip_as_int:{$gte:foo46, $lte:bar46}}, {ip_as_int:{$gte:foo47, $lte:bar47}}, {ip_as_int:{$gte:foo48, $lte:bar48}}, {ip_as_int:{$gte:foo49, $lte:bar49}}, {ip_as_int:{$gte:foo50, $lte:bar50}}, {ip_as_int:{$gte:foo51, $lte:bar51}}, {ip_as_int:{$gte:foo52, $lte:bar52}}, {ip_as_int:{$gte:foo53, $lte:bar53}}]});

      When I execute the query, the shell returns with "Error: error doing query: failed"

      The server crashes with:

      Thu Dec 23 16:30:57 [conn1] Uncaught std::exception: std::bad_alloc, terminating
      Thu Dec 23 16:30:57 dbexit:

      Thu Dec 23 16:30:57 [conn1] shutdown: going to close listening sockets...
      Thu Dec 23 16:30:57 [conn1] closing listening socket: 5
      Thu Dec 23 16:30:57 [conn1] closing listening socket: 6
      Thu Dec 23 16:30:57 [conn1] closing listening socket: 7
      Thu Dec 23 16:30:57 [conn1] closing listening socket: 8
      Thu Dec 23 16:30:57 [conn1] shutdown: going to flush oplog...
      Thu Dec 23 16:30:57 [conn1] shutdown: going to close sockets...
      Thu Dec 23 16:30:57 [initandlisten] now exiting
      Thu Dec 23 16:30:57 dbexit: ; exiting immediately

      Thu Dec 23 16:30:57 [conn1] shutdown: waiting for fs preallocator...
      Thu Dec 23 16:30:57 [conn1] shutdown: closing all files...
      mongod: /opt/boost/include/boost/thread/pthread/mutex.hpp:50: void boost::mutex::lock(): Assertion `!pthread_mutex_lock(&m)' failed.
      Thu Dec 23 16:30:57 Got signal: 6 (Aborted).

      Thu Dec 23 16:30:58 Backtrace:
      0x84a7552 0xb7f97400 0xb7f97430 0xb7d096d0 0xb7d0b098 0xb7d025ce 0x815c120 0x815ac44 0x835f182 0x835f97f 0x84a654c 0x81cd468 0x84bf1bd 0xb7e474ff 0xb7dc25ee
      mongod(_ZN5mongo10abruptQuitEi+0x3c2) [0x84a7552]
      [0xb7f97400]
      [0xb7f97430]
      /lib/tls/i686/cmov/libc.so.6(gsignal+0x50) [0xb7d096d0]
      /lib/tls/i686/cmov/libc.so.6(abort+0x188) [0xb7d0b098]
      /lib/tls/i686/cmov/libc.so.6(__assert_fail+0xee) [0xb7d025ce]
      mongod(_ZN5mongo6rwlockC1ERKNS_6RWLockEbb+0x160) [0x815c120]
      mongod(_ZN5mongo9MongoFile13closeAllFilesERSt18basic_stringstreamIcSt11char_traitsIcESaIcEE+0x84) [0x815ac44]
      mongod(_ZN5mongo8shutdownEv+0x412) [0x835f182]
      mongod(_ZN5mongo6dbexitENS_8ExitCodeEPKc+0x18f) [0x835f97f]
      mongod(_ZN5mongo10connThreadEPNS_13MessagingPortE+0x10cc) [0x84a654c]
      mongod(_ZN5boost6detail11thread_dataINS_3_bi6bind_tIvPFvPN5mongo13MessagingPortEENS2_5list1INS2_5valueIS6_EEEEEEE3runEv+0x18) [0x81cd468]
      mongod(thread_proxy+0x7d) [0x84bf1bd]
      /lib/tls/i686/cmov/libpthread.so.0 [0xb7e474ff]
      /lib/tls/i686/cmov/libc.so.6(clone+0x5e) [0xb7dc25ee]

      If I repair, restart and run the query with a third of the expressions to "$or", the server stays online and returns results. I also ran separate queries for each of the 54 queries with success. It turns out that running each of the 54 queries separately returns a grand total of 20 documents from the database.

      I'd like to be able to run the single query with all 54 expressions for "$or". Is there something preventing the server from returning results for a 54 argument query, or should the query be able to complete as is?

      Attachments

        Activity

          People

            aaron Aaron Staple
            amz4f Tony Zanella
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: