0
0
mirror of https://github.com/mongodb/mongo.git synced 2024-12-01 09:32:32 +01:00

Merge branch 'master' of git@github.com:mongodb/mongo

This commit is contained in:
Aaron 2009-03-26 18:37:49 -04:00
commit 07dfc6bb3a
6 changed files with 19 additions and 7 deletions

View File

@ -44,6 +44,7 @@ namespace mongo {
if ( _id.isEmpty() ){
OID oid;
oid.init();
b.appendOID( "_id" , &oid );
BSONObj o = b.obj();

View File

@ -44,7 +44,7 @@ s.adminCommand( { moveshard : "test.foo" , find : { num : 1 } , to : seconday.ge
assert.eq( 2 , seconday.foo.find().length() , "seconday should have 2 after move shard" );
assert.eq( 1 , primary.foo.find().length() , "primary should only have 1 after move shard" );
assert.eq( 2 , s.config.shard.count() , "still should have 2 shards" );
assert.eq( 2 , s.config.shard.count() , "still should have 2 shards after move not:" + s.config.shard.find().toArray().tojson( true ) );
shards = s.config.shard.find().toArray();
assert.neq( shards[0].server , shards[1].server , "servers should NOT be the same after the move" );

View File

@ -25,6 +25,7 @@ function simpleFindOne(){
return a2.getMongo().getDB( "alleyinsider" ).foo.findOne();
}
assert.commandWorked( a2.runCommand( { "setShardVersion" : "alleyinsider.bar" , configdb : s._configDB , version : 2 , authoritative : true } ) , "setShardVersion bar temp");
assert.throws( simpleFindOne , [] , "should complain about not in sharded mode 1" );
assert( a2.runCommand( { "setShardVersion" : "alleyinsider.foo" , configdb : s._configDB , version : 2 } ).ok == 1 , "setShardVersion a2-1");
simpleFindOne(); // now should run ok

View File

@ -72,9 +72,9 @@ namespace mongo {
}
ShardManager* DBConfig::getShardManager( const string& ns ){
ShardManager* DBConfig::getShardManager( const string& ns , bool reload ){
ShardManager* m = _shards[ns];
if ( m )
if ( m && ! reload )
return m;
uassert( (string)"not sharded:" + ns , sharded( ns ) );

View File

@ -62,7 +62,7 @@ namespace mongo {
*/
bool sharded( const string& ns );
ShardManager* getShardManager( const string& ns );
ShardManager* getShardManager( const string& ns , bool reload = false );
/**
* @return the correct for machine for the ns

View File

@ -120,7 +120,9 @@ namespace mongo {
unsigned long long& oldVersion = (*versions)[ns];
if ( version < oldVersion ){
errmsg = "going to older version for you!";
errmsg = "you already have a newer version";
result.appendTimestamp( "oldVersion" , oldVersion );
result.appendTimestamp( "newVersion" , version );
return false;
}
@ -194,11 +196,19 @@ namespace mongo {
NSVersions * versions = clientShardVersions.get();
if ( ! versions ){
errmsg = ns + " in sharded mode, but client not in sharded mode";
return false;
// this means the client has nothing sharded
// so this allows direct connections to do whatever they want
// which i think is the correct behavior
return true;
}
unsigned long long clientVersion = (*versions)[ns];
if ( clientVersion == 0 ){
errmsg = "client in sharded mode, but doesn't have version set for this collection";
return false;
}
if ( clientVersion >= version ){
return true;
}