diff options
author | Antonin Kral <a.kral@bobek.cz> | 2011-12-15 10:02:19 +0100 |
---|---|---|
committer | Antonin Kral <a.kral@bobek.cz> | 2011-12-15 10:02:46 +0100 |
commit | 0b48f8ada2acb0de830b23f8cefc8e3fea28d915 (patch) | |
tree | f7c2811269b6b53199412be2dd5ec02eea15d55d /s/shard.cpp | |
parent | 85f1cd56145b90a32b7ccdc750000deeed54fe22 (diff) | |
parent | f0d9a01bccdaeb466c12c92057914bbfef59526c (diff) | |
download | mongodb-0b48f8ada2acb0de830b23f8cefc8e3fea28d915.tar.gz |
Merge branch 'upstream/2.0.2'
Diffstat (limited to 's/shard.cpp')
-rw-r--r-- | s/shard.cpp | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/s/shard.cpp b/s/shard.cpp index 75326e0..7d06a31 100644 --- a/s/shard.cpp +++ b/s/shard.cpp @@ -365,12 +365,26 @@ namespace mongo { conn->auth("local", internalSecurity.user, internalSecurity.pwd, err, false)); } - if ( _shardedConnections ) { - conn->simpleCommand( "admin" , 0 , "setShardVersion" ); + if ( _shardedConnections && isVersionableCB( conn ) ) { + + // We must initialize sharding on all connections, so that we get exceptions if sharding is enabled on + // the collection. + BSONObj result; + bool ok = initShardVersionCB( *conn, result ); + + // assert that we actually successfully setup sharding + uassert( 15907, str::stream() << "could not initialize sharding on connection " << (*conn).toString() << + ( result["errmsg"].type() == String ? causedBy( result["errmsg"].String() ) : + causedBy( (string)"unknown failure : " + result.toString() ) ), ok ); + } } - void ShardingConnectionHook::onDestory( DBClientBase * conn ) { - resetShardVersionCB( conn ); + void ShardingConnectionHook::onDestroy( DBClientBase * conn ) { + + if( _shardedConnections && isVersionableCB( conn ) ){ + resetShardVersionCB( conn ); + } + } } |