mirror of
https://github.com/mongodb/mongo.git
synced 2024-12-01 09:32:32 +01:00
cleaning and don't allow group on a sharded collection SHARDING-26
This commit is contained in:
parent
467dc24e82
commit
c53e909ced
@ -38,14 +38,14 @@ for ( ; i<1500; i++ ){
|
||||
}
|
||||
|
||||
assert.eq( 3 , s.config.chunks.count() , "shard didn't split A " );
|
||||
s.printShards();
|
||||
s.printChunks();
|
||||
|
||||
for ( ; i<3000; i++ ){
|
||||
coll.save( { num : i , s : bigString } );
|
||||
}
|
||||
|
||||
assert.eq( 4 , s.config.chunks.count() , "shard didn't split B " );
|
||||
s.printShards();
|
||||
s.printChunks();
|
||||
|
||||
|
||||
s.stop();
|
||||
|
@ -31,7 +31,7 @@ s.adminCommand( "connpoolsync" );
|
||||
print( "done inserting data" );
|
||||
|
||||
print( "datasize: " + tojson( s.getServer( "test" ).getDB( "admin" ).runCommand( { datasize : "test.foo" } ) ) );
|
||||
s.printShards();
|
||||
s.printChunks();
|
||||
|
||||
counta = s._connections[0].getDB( "test" ).foo.count();
|
||||
countb = s._connections[1].getDB( "test" ).foo.count();
|
||||
|
@ -101,7 +101,25 @@ assert( db.foo5.isCapped() , "cb1" );
|
||||
assert( ! s.admin.runCommand( { shardcollection : "test.foo5" , key : { num : 1 } } ).ok , "shard capped" );
|
||||
|
||||
|
||||
// ----- group ----
|
||||
|
||||
db.foo6.save( { a : 1 } );
|
||||
db.foo6.save( { a : 3 } );
|
||||
db.foo6.save( { a : 3 } );
|
||||
s.sync();
|
||||
|
||||
assert.eq( 2 , db.foo6.group( { key : { a : 1 } , initial : { count : 0 } ,
|
||||
reduce : function(z,prev){ prev.count++; } } ).length );
|
||||
|
||||
assert.eq( 3 , db.foo6.find().count() );
|
||||
assert( s.admin.runCommand( { shardcollection : "test.foo6" , key : { a : 2 } } ).ok );
|
||||
assert.eq( 3 , db.foo6.find().count() );
|
||||
|
||||
s.adminCommand( { split : "test.foo6" , middle : { a : 2 } } );
|
||||
s.adminCommand( { movechunk : "test.foo6" , find : { a : 3 } , to : s.getOther( s.getServer( "test" ) ).name } );
|
||||
|
||||
assert.throws( function(){ db.foo6.group( { key : { a : 1 } , initial : { count : 0 } , reduce : function(z,prev){ prev.count++; } } ); } );;
|
||||
|
||||
|
||||
s.stop()
|
||||
|
||||
|
@ -26,7 +26,7 @@ s.adminCommand( { split : "test.foo" , find : { name : "joe" } } );
|
||||
|
||||
s.adminCommand( { movechunk : "test.foo" , find : { name : "joe" } , to : seconday.getMongo().name } );
|
||||
|
||||
s.printShards();
|
||||
s.printChunks();
|
||||
|
||||
assert.eq( 3 , primary.foo.find().toArray().length , "primary count" );
|
||||
assert.eq( 3 , seconday.foo.find().toArray().length , "secondary count" );
|
||||
|
@ -50,7 +50,7 @@ s.adminCommand( { movechunk : "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.chunks.count() , "still should have 2 shards after move not:" + s.getShardString() );
|
||||
assert.eq( 2 , s.config.chunks.count() , "still should have 2 shards after move not:" + s.getChunksString() );
|
||||
chunks = s.config.chunks.find().toArray();
|
||||
assert.neq( chunks[0].shard , chunks[1].shard , "servers should NOT be the same after the move" );
|
||||
|
||||
|
@ -31,7 +31,7 @@ assert.eq( 7 , s2.getDB( "test" ).foo.find().toArray().length , "other B" );
|
||||
|
||||
s.adminCommand( { split : "test.foo" , middle : { num : 2 } } );
|
||||
//s.adminCommand( { movechunk : "test.foo" , find : { num : 3 } , to : s.getOther( s.getServer( "test" ) ).name } );
|
||||
s.printShards();
|
||||
s.printChunks();
|
||||
|
||||
print( "* A" );
|
||||
|
||||
|
@ -33,7 +33,7 @@ assert.eq( 7 , s2.getDB( "test" ).foo.find().toArray().length , "other B" );
|
||||
|
||||
s.adminCommand( { split : "test.foo" , middle : { num : 2 } } );
|
||||
//s.adminCommand( { movechunk : "test.foo" , find : { num : 3 } , to : s.getOther( s.getServer( "test" ) ).name } );
|
||||
s.printShards()
|
||||
s.printChunks()
|
||||
|
||||
print( "* A" );
|
||||
|
||||
|
@ -26,7 +26,7 @@ assert.eq( s.admin.runCommand( { splitvalue : "test.foo" , find : { a : 3 } } ).
|
||||
s.adminCommand( { split : "test.foo" , find : { a : 99 } } );
|
||||
|
||||
assert.eq( s.config.chunks.count() , 3 );
|
||||
s.printShards();
|
||||
s.printChunks();
|
||||
|
||||
assert.eq( s.admin.runCommand( { splitvalue : "test.foo" , find : { a : 50 } } ).middle.a , 10 , "splitvalue 4 " );
|
||||
|
||||
|
@ -174,7 +174,10 @@ namespace mongo {
|
||||
{
|
||||
|
||||
ShardChunkVersion newVersion = _manager->getVersion( from );
|
||||
uassert( "version has to be higher" , newVersion > oldVersion );
|
||||
if ( newVersion <= oldVersion ){
|
||||
log() << "newVersion: " << newVersion << " oldVersion: " << oldVersion << endl;
|
||||
uassert( "version has to be higher" , newVersion > oldVersion );
|
||||
}
|
||||
|
||||
BSONObjBuilder b;
|
||||
b << "movechunk.finish" << _ns;
|
||||
|
@ -126,5 +126,18 @@ namespace mongo {
|
||||
}
|
||||
|
||||
} convertToCappedCmd;
|
||||
|
||||
|
||||
class GroupCmd : public NotAllowedOnShardedCollectionCmd {
|
||||
public:
|
||||
GroupCmd() : NotAllowedOnShardedCollectionCmd("group"){}
|
||||
|
||||
virtual string getFullNS( const string& dbName , const BSONObj& cmdObj ){
|
||||
return dbName + "." + cmdObj.firstElement().embeddedObjectUserCheck()["ns"].valuestrsafe();
|
||||
}
|
||||
|
||||
} groupCmd;
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -187,12 +187,15 @@ ShardingTest.prototype.adminCommand = function(cmd){
|
||||
throw "command " + tojson( cmd ) + " failed: " + tojson( res );
|
||||
}
|
||||
|
||||
ShardingTest.prototype.getShardString = function(){
|
||||
return Array.tojson( this.config.shard.find().toArray() , "\n" );
|
||||
ShardingTest.prototype.getChunksString = function( ns ){
|
||||
var q = {}
|
||||
if ( ns )
|
||||
q.ns = ns;
|
||||
return Array.tojson( this.config.chunks.find( q ).toArray() , "\n" );
|
||||
}
|
||||
|
||||
ShardingTest.prototype.printShards = function(){
|
||||
print( this.getShardString() );
|
||||
ShardingTest.prototype.printChunks = function( ns ){
|
||||
print( this.getChunksString( ns ) );
|
||||
}
|
||||
|
||||
ShardingTest.prototype.sync = function(){
|
||||
|
Loading…
Reference in New Issue
Block a user