Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

don't use lazy on connection types where it can't work

  • Loading branch information...
commit 5fafbffa275f7f877c55236ee5a92a27b0ce284b 1 parent e786370
@erh erh authored
View
5 client/dbclient.h
@@ -353,6 +353,7 @@ namespace mongo {
virtual void checkResponse( const char* data, int nReturned, bool* retry = NULL, string* targetHost = NULL ) {
if( retry ) *retry = false; if( targetHost ) *targetHost = "";
}
+ virtual bool lazySupported() const = 0;
};
/**
@@ -921,13 +922,15 @@ namespace mongo {
void setSoTimeout(double to) { _so_timeout = to; }
double getSoTimeout() const { return _so_timeout; }
+ virtual bool lazySupported() const { return true; }
+
static int getNumConnections() {
return _numConnections;
}
static void setLazyKillCursor( bool lazy ) { _lazyKillCursor = lazy; }
static bool getLazyKillCursor() { return _lazyKillCursor; }
-
+
protected:
friend class SyncClusterConnection;
virtual void sayPiggyBack( Message &toSend );
View
1  client/dbclient_rs.h
@@ -246,6 +246,7 @@ namespace mongo {
string getServerAddress() const { return _monitor->getServerAddress(); }
virtual ConnectionString::ConnectionType type() const { return ConnectionString::SET; }
+ virtual bool lazySupported() const { return true; }
// ---- low level ------
View
1  client/dbclientcursor.cpp
@@ -70,6 +70,7 @@ namespace mongo {
}
void DBClientCursor::initLazy( bool isRetry ) {
+ verify( 15875 , _client->lazySupported() );
Message toSend;
_assembleInit( toSend );
_client->say( toSend, isRetry );
View
12 client/parallel.cpp
@@ -729,9 +729,15 @@ namespace mongo {
_connHolder.reset( new ScopedDbConnection( _server ) );
_conn = _connHolder->get();
}
-
- _cursor.reset( new DBClientCursor(_conn, _db + ".$cmd", _cmd, -1/*limit*/, 0, NULL, _options, 0));
- _cursor->initLazy();
+
+ if ( _conn->lazySupported() ) {
+ _cursor.reset( new DBClientCursor(_conn, _db + ".$cmd", _cmd, -1/*limit*/, 0, NULL, _options, 0));
+ _cursor->initLazy();
+ }
+ else {
+ _done = true; // we set _done first because even if there is an error we're done
+ _ok = _conn->runCommand( db , cmd , _res , options );
+ }
}
catch ( std::exception& e ) {
error() << "Future::spawnComand (part 1) exception: " << e.what() << endl;
View
1  client/syncclusterconnection.h
@@ -96,6 +96,7 @@ namespace mongo {
virtual bool auth(const string &dbname, const string &username, const string &password_text, string& errmsg, bool digestPassword);
+ virtual bool lazySupported() const { return false; }
private:
SyncClusterConnection( SyncClusterConnection& prev, double socketTimeout = 0 );
string _toString() const;
View
2  db/instance.h
@@ -147,6 +147,8 @@ namespace mongo {
virtual ConnectionString::ConnectionType type() const { return ConnectionString::MASTER; }
double getSoTimeout() const { return 0; }
+
+ virtual bool lazySupported() const { return true; }
private:
static HostAndPort _clientHost;
};
View
38 jstests/sharding/parallel.js
@@ -0,0 +1,38 @@
+numShards = 3
+s = new ShardingTest( "parallel" , numShards , 2 , 2 , { sync : true } );
+
+s.adminCommand( { enablesharding : "test" } );
+s.adminCommand( { shardcollection : "test.foo" , key : { _id : 1 } } );
+
+db = s.getDB( "test" );
+
+N = 10000;
+
+for ( i=0; i<N; i+=(N/12) ) {
+ s.adminCommand( { split : "test.foo" , middle : { _id : i } } )
+ sh.moveChunk( "test.foo", { _id : i } , "shard000" + Math.floor( Math.random() * numShards ) )
+}
+
+
+for ( i=0; i<N; i++ )
+ db.foo.insert( { _id : i } )
+db.getLastError();
+
+
+doCommand = function( dbname , cmd ) {
+ x = benchRun( { ops : [ { op : "findOne" , ns : dbname + ".$cmd" , query : cmd } ] ,
+ host : db.getMongo().host , parallel : 2 , seconds : 2 } )
+ printjson(x)
+ x = benchRun( { ops : [ { op : "findOne" , ns : dbname + ".$cmd" , query : cmd } ] ,
+ host : s._mongos[1].host , parallel : 2 , seconds : 2 } )
+ printjson(x)
+}
+
+doCommand( "test" , { dbstats : 1 } )
+doCommand( "config" , { dbstats : 1 } )
+
+x = s.getDB( "config" ).stats()
+assert( x.ok , tojson(x) )
+printjson(x)
+
+s.stop()
Please sign in to comment.
Something went wrong with that request. Please try again.