Skip to content

Commit d6a3897

Browse files
committed
SERVER-6391 - don't sleep if we're a reader,
and call ElapsedTracker::resetLastTime when we're done sleeping
1 parent 47d00c2 commit d6a3897

File tree

1 file changed

+18
-6
lines changed

1 file changed

+18
-6
lines changed

src/mongo/db/clientcursor.cpp

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -511,7 +511,9 @@ namespace mongo {
511511
if ( yielded ) {
512512
*yielded = true;
513513
}
514-
return yield( suggestYieldMicros() , rec );
514+
bool res = yield( suggestYieldMicros() , rec );
515+
_yieldSometimesTracker.resetLastTime();
516+
return res;
515517
}
516518
return true;
517519
}
@@ -521,12 +523,16 @@ namespace mongo {
521523
if ( yielded ) {
522524
*yielded = true;
523525
}
524-
return yield( micros , _recordForYield( need ) );
526+
bool res = yield( micros , _recordForYield( need ) );
527+
_yieldSometimesTracker.resetLastTime();
528+
return res;
525529
}
526530
return true;
527531
}
528532

529533
void ClientCursor::staticYield( int micros , const StringData& ns , Record * rec ) {
534+
bool haveReadLock = Lock::isReadLocked();
535+
530536
killCurrentOp.checkForInterrupt( false );
531537
{
532538
auto_ptr<LockMongoFilesShared> lk;
@@ -537,10 +543,16 @@ namespace mongo {
537543

538544
dbtempreleasecond unlock;
539545
if ( unlock.unlocked() ) {
540-
if ( micros == -1 )
541-
micros = Client::recommendedYieldMicros();
542-
if ( micros > 0 )
543-
sleepmicros( micros );
546+
if ( haveReadLock ) {
547+
// don't sleep with a read lock
548+
}
549+
else {
550+
if ( micros == -1 )
551+
micros = Client::recommendedYieldMicros();
552+
if ( micros > 0 )
553+
sleepmicros( micros );
554+
}
555+
544556
}
545557
else if ( Listener::getTimeTracker() == 0 ) {
546558
// we aren't running a server, so likely a repair, so don't complain

0 commit comments

Comments
 (0)