diff --git a/db/cloner.cpp b/db/cloner.cpp index 4816b11877f..ef0f720f74c 100644 --- a/db/cloner.cpp +++ b/db/cloner.cpp @@ -270,8 +270,14 @@ namespace mongo { c = conn->query( logNS.c_str(), Query(), 0, 0, 0, Option_CursorTailable ); } cout << "start cursorId: " << c->getCursorId() << endl; - replayOpLog( c.get(), query ); - cursorId = c->getCursorId(); + if ( c->more() ) { + replayOpLog( c.get(), query ); + cursorId = c->getCursorId(); + massert( "Expected valid tailing cursor", cursorId != 0 ); + } else { + massert( "Did not expect valid cursor for empty query result", c->getCursorId() == 0 ); + cursorId = 0; + } cout << "set cursorId: " << cursorId << endl; c->decouple(); return true; @@ -298,6 +304,8 @@ namespace mongo { char db[256]; nsToClient( ns, db ); + cout << "using cursorId: " << cursorId << endl; + auto_ptr< DBClientCursor > cur; { dbtemprelease r; @@ -308,7 +316,10 @@ namespace mongo { return false; conn = c; string logNS = "local.temp.oplog." + string( ns ); - cur = conn->getMore( logNS.c_str(), cursorId ); + if ( cursorId != 0 ) + cur = conn->getMore( logNS.c_str(), cursorId ); + else + cur = conn->query( logNS.c_str(), Query() ); } replayOpLog( cur.get(), query ); { @@ -441,10 +452,10 @@ namespace mongo { cursorId = cursorIdToken.date(); cout << "val: " << cursorIdToken.date() << endl; } - if ( cursorId == 0 ) { - errmsg = "invalid cursorId spec"; - return false; - } +// if ( cursorId == 0 ) { +// errmsg = "invalid cursorId spec"; +// return false; +// } setClient( collection.c_str() ); diff --git a/db/pdfile.cpp b/db/pdfile.cpp index da909b8f6bb..eb39ed84a4a 100644 --- a/db/pdfile.cpp +++ b/db/pdfile.cpp @@ -949,7 +949,7 @@ assert( !eloc.isNull() ); Timer t; Nullstream& l = log(); - l << "building new index for " << ns << "..."; + l << "building new index on " << idx.keyPattern() << " for " << ns << "..."; l.flush(); int err = 0; int n = 0; diff --git a/db/query.cpp b/db/query.cpp index f26a8899b08..f6c11b54565 100644 --- a/db/query.cpp +++ b/db/query.cpp @@ -511,22 +511,24 @@ namespace mongo { int n = 0; if ( !cc ) { - DEV log() << "getMore: cursorid not found " << ns << " " << cursorid << endl; + log() << "getMore: cursorid not found " << ns << " " << cursorid << endl; cursorid = 0; resultFlags = QueryResult::ResultFlag_CursorNotFound; } else { + log() << "getMore: cursorid found " << ns << " " << cursorid << endl; start = cc->pos; Cursor *c = cc->c.get(); c->checkLocation(); c->tailResume(); while ( 1 ) { if ( !c->ok() ) { + cout << "tailing? : " << c->tailing() << endl; if ( c->tailing() ) { c->setAtTail(); break; } - DEV log() << " getmore: last batch, erasing cursor " << cursorid << endl; + log() << " getmore: last batch, erasing cursor " << cursorid << endl; bool ok = ClientCursor::erase(cursorid); assert(ok); cursorid = 0;