[SERVER-9598] mongoDB server crashes when using min() / max() with descending order sort Created: 06/May/13  Updated: 08/May/13  Resolved: 06/May/13

Status: Closed
Project: Core Server
Component/s: Querying
Affects Version/s: 2.2.0
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: George Thompson Assignee: Unassigned
Resolution: Duplicate Votes: 0
Labels: crash, query
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Windows 7 64 bit SP1


Issue Links:
Duplicate
duplicates SERVER-3766 Assertion failure la <= 0xffffff db/b... Closed
Operating System: Windows
Steps To Reproduce:

See description.

Participants:

 Description   

Possibly related to SERVER-9547 which demonstrates that:

db.docs.drop()
for (var i=0; i<10; i++) { db.docs.insert({number: i}) }
db.docs.ensureIndex({number: 1})

with a descending sort

db.docs.find().max({number: 4}).sort({number: -1})

returns 0 documents.

On my system with a debug build of mongoDB, instead it crashes my server.

Mon May 06 10:25:34 [conn1]  TESTCRASH.docs Assertion failure la <= 0xffffff c:\mongodb\src\mongo\db\btree.h 243
Mon May 06 10:25:38 [conn1] mongod.exe  ...\src\mongo\util\stacktrace.cpp(161)              mongo::printStackTrace+0x5b
Mon May 06 10:25:38 [conn1] mongod.exe  ...\src\mongo\util\log.cpp(435)                     mongo::logContext+0x72
Mon May 06 10:25:38 [conn1] mongod.exe  ...\src\mongo\util\assert_util.cpp(109)             mongo::verifyFailed+0x190
Mon May 06 10:25:38 [conn1] mongod.exe  ...\src\mongo\db\btree.h(243)                       mongo::DiskLoc56Bit::operator=+0x7a
Mon May 06 10:25:38 [conn1] mongod.exe  ...\src\mongo\db\btree.cpp(751)                     mongo::BtreeBucket<mongo::BtreeData_V1>::find+0x64
Mon May 06 10:25:38 [conn1] mongod.exe  ...\src\mongo\db\btree.cpp(1512)                    mongo::BtreeBucket<mongo::BtreeData_V1>::locate+0x74
Mon May 06 10:25:38 [conn1] mongod.exe  ...\src\mongo\db\btree.cpp(1506)                    mongo::BtreeBucket<mongo::BtreeData_V1>::locate+0xd2
Mon May 06 10:25:38 [conn1] mongod.exe  ...\src\mongo\db\btreecursor.cpp(173)               mongo::BtreeCursorImpl<mongo::BtreeData_V1>::_locate+0xdd
Mon May 06 10:25:38 [conn1] mongod.exe  ...\src\mongo\db\btreecursor.cpp(289)               mongo::BtreeCursor::initWithoutIndependentFieldRanges+0x1df
Mon May 06 10:25:38 [conn1] mongod.exe  ...\src\mongo\db\btreecursor.cpp(227)               mongo::BtreeCursor::make+0xba
Mon May 06 10:25:38 [conn1] mongod.exe  ...\src\mongo\db\queryoptimizer.cpp(296)            mongo::QueryPlan::newCursor+0x388
Mon May 06 10:25:38 [conn1] mongod.exe  ...\src\mongo\db\queryoptimizercursorimpl.cpp(821)  mongo::CursorGenerator::singlePlanCursor+0x189
Mon May 06 10:25:38 [conn1] mongod.exe  ...\src\mongo\db\queryoptimizercursorimpl.cpp(845)  mongo::CursorGenerator::generate+0xbf
Mon May 06 10:25:38 [conn1] mongod.exe  ...\src\mongo\db\queryoptimizercursorimpl.cpp(724)  mongo::NamespaceDetailsTransient::getCursor+0xbf
Mon May 06 10:25:38 [conn1] mongod.exe  ...\src\mongo\db\ops\query.cpp(662)                 mongo::queryWithQueryOptimizer+0x1a9
Mon May 06 10:25:38 [conn1] mongod.exe  ...\src\mongo\db\ops\query.cpp(1015)                mongo::runQuery+0x112f
Mon May 06 10:25:38 [conn1] mongod.exe  ...\src\mongo\db\instance.cpp(244)                  mongo::receivedQuery+0x155
Mon May 06 10:25:38 [conn1] mongod.exe  ...\src\mongo\db\instance.cpp(390)                  mongo::assembleResponse+0x37d
Mon May 06 10:25:38 [conn1] mongod.exe  ...\src\mongo\db\db.cpp(192)                        mongo::MyMessageHandler::process+0x133
Mon May 06 10:25:38 [conn1] mongod.exe  ...\src\mongo\util\net\message_server_port.cpp(86)  mongo::pms::threadRun+0x638
Mon May 06 10:25:38 [conn1] *** unhandled exception 0x80000003 at 0x000007FEFDF03172, terminating
Mon May 06 10:25:38 [conn1] *** stack trace for unhandled exception:
Mon May 06 10:25:39 [conn1] KERNELBASE.dll                                                      DebugBreak+0x2
Mon May 06 10:25:39 [conn1] mongod.exe      ...\src\mongo\util\debug_util.cpp(46)               mongo::mongo_breakpoint+0x22
Mon May 06 10:25:39 [conn1] mongod.exe      ...\src\mongo\util\debug_util.h(65)                 mongo::breakpoint+0x25
Mon May 06 10:25:39 [conn1] mongod.exe      ...\src\mongo\util\assert_util.cpp(116)             mongo::verifyFailed+0x2b0
Mon May 06 10:25:39 [conn1] mongod.exe      ...\src\mongo\db\btree.h(243)                       mongo::DiskLoc56Bit::operator=+0x7a
Mon May 06 10:25:39 [conn1] mongod.exe      ...\src\mongo\db\btree.cpp(751)                     mongo::BtreeBucket<mongo::BtreeData_V1>::find+0x64
Mon May 06 10:25:39 [conn1] mongod.exe      ...\src\mongo\db\btree.cpp(1512)                    mongo::BtreeBucket<mongo::BtreeData_V1>::locate+0x74
Mon May 06 10:25:39 [conn1] mongod.exe      ...\src\mongo\db\btree.cpp(1506)                    mongo::BtreeBucket<mongo::BtreeData_V1>::locate+0xd2
Mon May 06 10:25:39 [conn1] mongod.exe      ...\src\mongo\db\btreecursor.cpp(173)               mongo::BtreeCursorImpl<mongo::BtreeData_V1>::_locate+0xdd
Mon May 06 10:25:39 [conn1] mongod.exe      ...\src\mongo\db\btreecursor.cpp(289)               mongo::BtreeCursor::initWithoutIndependentFieldRanges+0x1df
Mon May 06 10:25:39 [conn1] mongod.exe      ...\src\mongo\db\btreecursor.cpp(227)               mongo::BtreeCursor::make+0xba
Mon May 06 10:25:39 [conn1] mongod.exe      ...\src\mongo\db\queryoptimizer.cpp(296)            mongo::QueryPlan::newCursor+0x388
Mon May 06 10:25:39 [conn1] mongod.exe      ...\src\mongo\db\queryoptimizercursorimpl.cpp(821)  mongo::CursorGenerator::singlePlanCursor+0x189
Mon May 06 10:25:39 [conn1] mongod.exe      ...\src\mongo\db\queryoptimizercursorimpl.cpp(845)  mongo::CursorGenerator::generate+0xbf
Mon May 06 10:25:39 [conn1] mongod.exe      ...\src\mongo\db\queryoptimizercursorimpl.cpp(724)  mongo::NamespaceDetailsTransient::getCursor+0xbf
Mon May 06 10:25:39 [conn1] mongod.exe      ...\src\mongo\db\ops\query.cpp(662)                 mongo::queryWithQueryOptimizer+0x1a9
Mon May 06 10:25:39 [conn1] mongod.exe      ...\src\mongo\db\ops\query.cpp(1015)                mongo::runQuery+0x112f
Mon May 06 10:25:39 [conn1] mongod.exe      ...\src\mongo\db\instance.cpp(244)                  mongo::receivedQuery+0x155
Mon May 06 10:25:39 [conn1] mongod.exe      ...\src\mongo\db\instance.cpp(390)                  mongo::assembleResponse+0x37d
Mon May 06 10:25:39 [conn1] mongod.exe      ...\src\mongo\db\db.cpp(192)                        mongo::MyMessageHandler::process+0x133
Mon May 06 10:25:39 [conn1] writing minidump diagnostic file mongo.dmp



 Comments   
Comment by George Thompson [ 07/May/13 ]

It appears that the assertion was fixed with

https://github.com/mongodb/mongo/commit/062652649915997e34ffd2e36bf6bf47edcf917f

but, as you discovered, apparently doesn't resolve the underlying issue of returning documents.

Comment by Tad Marshall [ 06/May/13 ]

Hi George,

Thanks for the report!

This seems to be SERVER-3766, which is scheduled to be fixed during the 2.6 development cycle.

It was reported against version 2.0.0-rc1 (a release candidate for version 2.0.0) and I reproduced it using your steps in version 2.0.2.

I tried to reproduce the assertion in the current (2.5.0-pre-) code and was unable to; I get no assertion in the current code.

It still shows the problem you reported in SERVER-9547; I get no documents, though I should.

Tad

Generated at Thu Feb 08 03:20:54 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.