Skip to content

Commit

Permalink
don't unset sharding state when a shard connection is done
Browse files Browse the repository at this point in the history
more prep for SERVER-1714
  • Loading branch information
erh committed May 19, 2011
1 parent 8d00901 commit 0b689c8
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 22 deletions.
4 changes: 4 additions & 0 deletions s/server.cpp
Expand Up @@ -72,6 +72,10 @@ namespace mongo {
virtual void onHandedOut( DBClientBase * conn ) {
ClientInfo::get()->addShard( conn->getServerAddress() );
}

virtual void onDestory( DBClientBase * conn ) {
resetShardVersionCB( conn );
}
};

class ShardedMessageHandler : public MessageHandler {
Expand Down
1 change: 1 addition & 0 deletions s/shard_version.h
Expand Up @@ -28,4 +28,5 @@ namespace mongo {
*/
void installChunkShardVersioning();


} // namespace mongo
26 changes: 4 additions & 22 deletions s/shardconnection.cpp
Expand Up @@ -67,8 +67,10 @@ namespace mongo {
if ( ss->avail ) {
/* if we're shutting down, don't want to initiate release mechanism as it is slow,
and isn't needed since all connections will be closed anyway */
if ( inShutdown() )
if ( inShutdown() ) {
resetShardVersionCB( ss->avail );
delete ss->avail;
}
else
release( addr , ss->avail );
ss->avail = 0;
Expand Down Expand Up @@ -137,27 +139,7 @@ namespace mongo {
}

void release( const string& addr , DBClientBase * conn ) {
resetShardVersionCB( conn );
BSONObj res;

try {
if ( conn->simpleCommand( "admin" , &res , "unsetSharding" ) ) {
shardConnectionPool.release( addr , conn );
}
else {
error() << "unset sharding failed : " << res << endl;
delete conn;
}
}
catch ( SocketException& e ) {
// server down or something
LOG(1) << "socket exception trying to unset sharding: " << e.toString() << endl;
delete conn;
}
catch ( std::exception& e ) {
error() << "couldn't unset sharding : " << e.what() << endl;
delete conn;
}
shardConnectionPool.release( addr , conn );
}

void _check( const string& ns ) {
Expand Down

0 comments on commit 0b689c8

Please sign in to comment.