Skip to content

Commit

Permalink
SERVER-6931 Don't attempt to look up a cursor using an invalid id. Pr…
Browse files Browse the repository at this point in the history
…events an occasional incorrect warning message.
  • Loading branch information
astaple authored and monkey101 committed Sep 12, 2012
1 parent bebd919 commit a530383
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
17 changes: 17 additions & 0 deletions jstests/cursorb.js
@@ -0,0 +1,17 @@
// The 'cursor not found in map -1' warning is not logged when get more exhausts a client cursor.
// SERVER-6931

t = db.jstests_cursorb;
t.drop();

// Exhaust a client cursor in get more.
for( i = 0; i < 200; ++i ) {
t.save( { a:i } );
}
t.find().itcount();

// Check that the 'cursor not found in map -1' message is not printed. This message indicates an
// attempt to look up a cursor with an invalid id and should never appear in the log.
log = db.adminCommand( { getLog:'global' } ).log
log.forEach( function( line ) { assert( !line.match( /cursor not found in map -1 / ),
'Cursor map lookup with id -1.' ); } );
2 changes: 1 addition & 1 deletion src/mongo/db/clientcursor.cpp
Expand Up @@ -792,7 +792,7 @@ namespace mongo {
if ( ! cc().getAuthenticationInfo()->isAuthorizedReads( nsToDatabase( cursor->ns() ) ) )
return false;

// mustn't have an active ClientCursor::Pointer
// Must not have an active ClientCursor::Pin.
massert( 16089,
str::stream() << "Cannot kill active cursor " << id,
cursor->_pinValue < 100 );
Expand Down
3 changes: 3 additions & 0 deletions src/mongo/db/clientcursor.h
Expand Up @@ -100,6 +100,9 @@ namespace mongo {
}
}
void release() {
if ( _cursorid == INVALID_CURSOR_ID ) {
return;
}
ClientCursor *cursor = c();
_cursorid = INVALID_CURSOR_ID;
if ( cursor ) {
Expand Down

0 comments on commit a530383

Please sign in to comment.