[SERVER-2283] MongoDB query using the $or operator with 54 expressions crashes mongod Created: 23/Dec/10 Updated: 30/Mar/12 Resolved: 28/Dec/10 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | None |
| Affects Version/s: | 1.6.5 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Tony Zanella | Assignee: | Aaron Staple |
| Resolution: | Duplicate | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Environment: |
Crunchbang Linux 9.04 |
||
| Operating System: | Linux |
| Participants: |
| 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 [conn1] shutdown: going to close listening sockets... Thu Dec 23 16:30:57 [conn1] shutdown: waiting for fs preallocator... Thu Dec 23 16:30:58 Backtrace: 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? |
| Comments |
| Comment by Tony Zanella [ 28/Dec/10 ] |
|
I upgraded the mongodb deb from mongodb-stable to mongodb-unstable, which is currently at 1.7.4, and the query works now. Thanks very much for the suggestion! |
| Comment by Aaron Staple [ 28/Dec/10 ] |
|
I think this is |
| Comment by Eliot Horowitz (Inactive) [ 23/Dec/10 ] |
|
Can you try 1.7.4? |