Details
-
Bug
-
Resolution: Done
-
Major - P3
-
None
-
2.5.2
-
Storage Execution
-
ALL
Description
The reIndex command fetches the target collection's list of indexes, drops them all, and then rebuilds each from the fetched list. The fetch of the index list is done with a system.indexes DBDirectClient query, and it is assumed that the result set was generated without errors. However, if the DBDirectClient sub-op is interrupted via killOp, the query will fail to return any index documents, and the collection will be left with zero indexes.
Reproduce by interrupting reIndex during the DBDirectClient initial query. The interruption point is Cursor::advance(). Interruption is allowed even while holding the write lock because no writes have yet been issued by the request.
Shell session (killOp not shown):
> db.foo.getIndexes()
|
[
|
{
|
"v" : 1, |
"key" : { |
"_id" : 1 |
},
|
"ns" : "test.foo", |
"name" : "_id_" |
},
|
{
|
"v" : 1, |
"key" : { |
"a" : 1 |
},
|
"ns" : "test.foo", |
"name" : "a_1" |
}
|
> db.foo.reIndex()
|
{
|
"nIndexesWas" : 2, |
"msg" : "indexes dropped for collection", |
"errmsg" : "exception: invalid ns to index", |
"code" : 10096, |
"ok" : 0 |
}
|
> db.foo.getIndexes()
|
[ ]
|
Stack trace for above, at interruption:
#0 mongo::KillCurrentOp::checkForInterrupt (this=0x101d291c0, heedMutex=true) at kill_current_op.cpp:128
|
#1 0x000000010031ead7 in mongo::BasicCursor::advance (this=0x10609abe0) at cursor.cpp:38
|
#2 0x00000001006103e4 in mongo::queryWithQueryOptimizer (queryOptions=4, ns=@0x106720150, jsobj=@0x10671fe30, curop=@0x1060f3700, query=@0x10671fde8, order=@0x10671fdf8, pq_shared=@0x10671fe48, oldPlan=@0x10671fd00, shardingVersionAtStart=@0x10671fd10, parentPageFaultSection=@0x10671fdd8, noPageFault=@0x10671fdd0, result=@0x106190370) at query.cpp:785
|
#3 0x00000001006167be in mongo::runQuery (m=@0x106721348, q=@0x106720750, curop=@0x1060f3700, result=@0x106190370) at query.cpp:1148
|
#4 0x000000010054627b in receivedQuery (c=@0x1061845b0, dbresponse=@0x106721228, m=@0x106721348) at instance.cpp:280
|
#5 0x000000010054a349 in mongo::assembleResponse (m=@0x106721348, dbresponse=@0x106721228, remote=@0x101d291b0) at instance.cpp:443
|
#6 0x000000010053b02d in mongo::DBDirectClient::call (this=0x101c98900, toSend=@0x106721348, response=@0x106190210, assertOk=false, actualServer=0x1061da118) at instance.cpp:1009
|
#7 0x000000010053b2cd in non-virtual thunk to mongo::DBDirectClient::call(mongo::Message&, mongo::Message&, bool, std::string*) () at instance.cpp:1022
|
#8 0x00000001000eaaa4 in mongo::DBClientCursor::init (this=0x1061da0f0) at dbclientcursor.cpp:66
|
#9 0x00000001000945cf in mongo::DBClientBase::query (this=0x101c98900, ns=@0x106721a68, query=@0x106721648, nToReturn=0, nToSkip=0, fieldsToReturn=0x0, queryOptions=4, batchSize=0) at dbclient.cpp:985
|
#10 0x000000010053a7e2 in mongo::DBDirectClient::query (this=0x101c98900, ns=@0x106721a68, query=@0x1067219c8, nToReturn=0, nToSkip=0, fieldsToReturn=0x0, queryOptions=4, batchSize=0) at instance.cpp:1029
|
#11 0x0000000100350093 in mongo::CmdReIndex::run (this=0x101d284f0, dbname=@0x1067224f8, jsobj=@0x106722aa0, unnamed_arg=false, errmsg=@0x1067224c8, result=@0x1067230d8, unnamed_arg=false) at dbcommands.cpp:780
|
#12 0x0000000100341766 in mongo::_execCommand (c=0x101d284f0, dbname=@0x1067224f8, cmdObj=@0x106722aa0, queryOptions=0, errmsg=@0x1067224c8, result=@0x1067230d8, fromRepl=false) at dbcommands.cpp:1963
|
#13 0x0000000100343efc in mongo::Command::execCommand (c=0x101d284f0, client=@0x1061845b0, queryOptions=0, cmdns=0x1060e6014 "test.$cmd", cmdObj=@0x106722aa0, result=@0x1067230d8, fromRepl=false) at dbcommands.cpp:2130
|
#14 0x00000001003452af in mongo::_runCommands (ns=0x1060e6014 "test.$cmd", _cmdobj=@0x1067231c0, b=@0x106723138, anObjBuilder=@0x1067230d8, fromRepl=false, queryOptions=0) at dbcommands.cpp:2194
|
#15 0x00000001006141d5 in mongo::runCommands (ns=0x1060e6014 "test.$cmd", jsobj=@0x1067231c0, curop=@0x1060f2c00, b=@0x106723138, anObjBuilder=@0x1067230d8, fromRepl=false, queryOptions=0) at query.cpp:68
|
#16 0x0000000100614fba in mongo::runQuery (m=@0x106724990, q=@0x106723ae0, curop=@0x1060f2c00, result=@0x1061902c0) at query.cpp:1045
|
#17 0x000000010054627b in receivedQuery (c=@0x1061845b0, dbresponse=@0x106724640, m=@0x106724990) at instance.cpp:280
|
#18 0x000000010054a349 in mongo::assembleResponse (m=@0x106724990, dbresponse=@0x106724640, remote=@0x106724690) at instance.cpp:443
|
#19 0x0000000100019f89 in mongo::MyMessageHandler::process (this=0x10608c0e8, m=@0x106724990, port=0x10609a1e0, le=0x1060a7400) at db.cpp:221
|
#20 0x0000000100bdfd2e in mongo::PortMessageServer::handleIncomingMsg (arg=0x1061d99a0) at message_server_port.cpp:210
|
#21 0x0000000100bde041 in boost::_bi::list1<boost::_bi::value<mongo::PortMessageServer::HandleIncomingMsgParam*> >::operator()<void*, void* (*)(void*), boost::_bi::list0> (this=0x1060b9df0, f=@0x1060b9de8, a=@0x106724e10, unnamed_arg=0) at bind.hpp:243
|
#22 0x0000000100bde0a6 in boost::_bi::bind_t<void*, void* (*)(void*), boost::_bi::list1<boost::_bi::value<mongo::PortMessageServer::HandleIncomingMsgParam*> > >::operator() (this=0x1060b9de8) at bind_template.hpp:20
|
#23 0x0000000100bde0e1 in boost::detail::thread_data<boost::_bi::bind_t<void*, void* (*)(void*), boost::_bi::list1<boost::_bi::value<mongo::PortMessageServer::HandleIncomingMsgParam*> > > >::run (this=0x1060b9c00) at thread.hpp:62
|
#24 0x0000000100cb6179 in thread_proxy (param=0x1060b9c00) at thread.cpp:121
|
#25 0x00007fff8bc7a782 in _pthread_start ()
|
#26 0x00007fff8bc671c1 in thread_start ()
|