Permalink
Browse files

only check shard version on 'top-level' shard connections SERVER-3926

fix with loglevel 1 added
  • Loading branch information...
1 parent 34c172c commit 771b5bca9a1200edbbd99a42f22c8bef4ee18eef gregs committed Jun 21, 2011
Showing with 39 additions and 11 deletions.
  1. +39 −11 s/shardconnection.cpp
View
@@ -79,6 +79,31 @@ namespace mongo {
DBClientBase * get( const string& addr , const string& ns ) {
_check( ns );
+ // Determine if non-shard conn is RS member for warning
+ // All shards added to _hosts if not present in _check()
+ if( logLevel >= 1 && _hosts.find( addr ) == _hosts.end() ){
+
+ vector<Shard> all;
+ Shard::getAllShards( all );
+
+ bool isRSMember = false;
+ string parentShard;
+ for ( unsigned i = 0; i < all.size(); i++ ) {
+ string connString = all[i].getConnString();
+ if( connString.find( addr ) != string::npos && connString.find( '/' ) != string::npos ){
+ isRSMember = true;
+ parentShard = connString;
+ break;
+ }
+ }
+
+ if( isRSMember ){
+ warning() << "adding shard sub-connection " << addr << " (parent " << parentShard << ") as sharded, this is safe but unexpected" << endl;
+ printStackTrace();
+ }
+ }
+
+
Status* &s = _hosts[addr];
if ( ! s )
s = new Status();
@@ -120,22 +145,25 @@ namespace mongo {
}
void checkVersions( const string& ns ) {
+
vector<Shard> all;
Shard::getAllShards( all );
+
+ // Now only check top-level shard connections
for ( unsigned i=0; i<all.size(); i++ ) {
- Status* &s = _hosts[all[i].getConnString()];
- if ( ! s )
+
+ string sconnString = all[i].getConnString();
+ Status* &s = _hosts[ sconnString ];
+
+ if ( ! s ){
s = new Status();
- }
+ }
+
+ if( ! s->avail )
+ s->avail = pool.get( sconnString );
+
+ checkShardVersionCB( *s->avail, ns, false, 1 );
- for ( HostMap::iterator i=_hosts.begin(); i!=_hosts.end(); ++i ) {
- if ( ! Shard::isAShardNode( i->first ) )
- continue;
- Status* ss = i->second;
- assert( ss );
- if ( ! ss->avail )
- ss->avail = pool.get( i->first );
- checkShardVersionCB( *ss->avail , ns , false , 1 );
}
}

0 comments on commit 771b5bc

Please sign in to comment.