diff --git a/jstests/cursorb.js b/jstests/cursorb.js new file mode 100644 index 0000000000000..65e356e89cbfa --- /dev/null +++ b/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.' ); } ); diff --git a/src/mongo/db/clientcursor.cpp b/src/mongo/db/clientcursor.cpp index 894927f3c866f..905456047afdd 100644 --- a/src/mongo/db/clientcursor.cpp +++ b/src/mongo/db/clientcursor.cpp @@ -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 ); diff --git a/src/mongo/db/clientcursor.h b/src/mongo/db/clientcursor.h index 9b478170e5c71..aebd23d4607b2 100644 --- a/src/mongo/db/clientcursor.h +++ b/src/mongo/db/clientcursor.h @@ -100,6 +100,9 @@ namespace mongo { } } void release() { + if ( _cursorid == INVALID_CURSOR_ID ) { + return; + } ClientCursor *cursor = c(); _cursorid = INVALID_CURSOR_ID; if ( cursor ) {