diff --git a/client/dbclientcursor.cpp b/client/dbclientcursor.cpp index d61522278d4..ddecfc34660 100644 --- a/client/dbclientcursor.cpp +++ b/client/dbclientcursor.cpp @@ -250,14 +250,20 @@ namespace mongo { if ( conn->get()->type() == ConnectionString::SET || conn->get()->type() == ConnectionString::SYNC ) { - _scopedHost = _client->getServerAddress(); + if( _lazy ) + _scopedHost = _lazy->getServerAddress(); + else if( _client ) + _scopedHost = _client->getServerAddress(); + else + massert(14821, "No client or lazy client specified, cannot store multi-host connection.", false); } else { _scopedHost = conn->getHost(); } - + conn->done(); _client = 0; + _lazy = 0; } DBClientCursor::~DBClientCursor() { diff --git a/jstests/slowNightly/sharding_rs2.js b/jstests/slowNightly/sharding_rs2.js index 60ff7f67cf8..4de935b64b2 100644 --- a/jstests/slowNightly/sharding_rs2.js +++ b/jstests/slowNightly/sharding_rs2.js @@ -157,6 +157,8 @@ assert.eq( 100 , ts.find().itcount() , "E5" ) printjson( ts.find().batchSize(5).explain() ) before = rs.test.getMaster().adminCommand( "serverStatus" ).opcounters +// Careful, mongos can poll the masters here too unrelated to the query, +// resulting in this test failing sporadically if/when there's a delay here. assert.eq( 100 , ts.find().batchSize(5).itcount() , "E6" ) after = rs.test.getMaster().adminCommand( "serverStatus" ).opcounters assert.eq( before.query + before.getmore , after.query + after.getmore , "E6.1" )