mirror of
https://github.com/mongodb/mongo.git
synced 2024-12-01 09:32:32 +01:00
finish first cut at migrate in mognod and lots of fixes SERVER-933
This commit is contained in:
parent
224ca4aecd
commit
92e8ad86fa
@ -62,12 +62,16 @@ assert( a.findOne( { num : 1 } ) )
|
||||
assert( b.findOne( { num : 1 } ) )
|
||||
|
||||
print( "GOING TO MOVE" );
|
||||
assert( a.findOne( { num : 1 } ) , "pre move 1" )
|
||||
s.printCollectionInfo( "test.foo" );
|
||||
s.adminCommand( { movechunk : "test.foo" , find : { num : 1 } , to : s.getOther( s.getServer( "test" ) ).name } );
|
||||
myto = s.getOther( s.getServer( "test" ) ).name
|
||||
print( "counts before move: " + tojson( s.shardCounts( "foo" ) ) );
|
||||
s.adminCommand( { movechunk : "test.foo" , find : { num : 1 } , to : myto } )
|
||||
print( "counts after move: " + tojson( s.shardCounts( "foo" ) ) );
|
||||
s.printCollectionInfo( "test.foo" );
|
||||
assert.eq( 1 , s.onNumShards( "foo" ) , "on 1 shard again" );
|
||||
assert( a.findOne( { num : 1 } ) )
|
||||
assert( b.findOne( { num : 1 } ) )
|
||||
assert( a.findOne( { num : 1 } ) , "post move 1" )
|
||||
assert( b.findOne( { num : 1 } ) , "post move 2" )
|
||||
|
||||
print( "*** drop" );
|
||||
|
||||
|
@ -360,6 +360,8 @@ namespace mongo {
|
||||
* @param me - so i don't get deleted before i'm done
|
||||
*/
|
||||
void drop( ChunkManagerPtr me );
|
||||
|
||||
void _printChunks() const;
|
||||
|
||||
private:
|
||||
|
||||
@ -395,7 +397,6 @@ namespace mongo {
|
||||
static AtomicUInt NextSequenceNumber;
|
||||
|
||||
bool _isValid() const;
|
||||
void _printChunks() const;
|
||||
|
||||
/**
|
||||
* @return number of Chunk matching the query or -1 for all chunks.
|
||||
|
@ -441,7 +441,7 @@ namespace mongo {
|
||||
errmsg = "no chunk manager?";
|
||||
return false;
|
||||
}
|
||||
|
||||
cm->_printChunks();
|
||||
result.appendTimestamp( "version" , cm->getVersion().toLong() );
|
||||
|
||||
return 1;
|
||||
|
@ -206,7 +206,14 @@ namespace mongo {
|
||||
++myVersion;
|
||||
temp2.appendTimestamp( "lastmod" , myVersion );
|
||||
|
||||
shardingState.setVersion( ns , myVersion );
|
||||
|
||||
conn->update( ShardNS::chunk , x["_id"].wrap() , BSON( "$set" << temp2.obj() ) );
|
||||
|
||||
}
|
||||
else {
|
||||
//++myVersion;
|
||||
shardingState.setVersion( ns , 0 );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -376,10 +376,15 @@ namespace mongo {
|
||||
errmsg = "need to speciy fully namespace";
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
ConfigVersion& oldVersion = info->getVersion(ns);
|
||||
unsigned long long& globalVersion = shardingState.getVersion(ns);
|
||||
|
||||
if ( oldVersion > 0 && globalVersion == 0 ){
|
||||
// this had been reset
|
||||
oldVersion = 0;
|
||||
}
|
||||
|
||||
if ( version == 0 && globalVersion == 0 ){
|
||||
// this connection is cleaning itself
|
||||
oldVersion = 0;
|
||||
@ -407,6 +412,7 @@ namespace mongo {
|
||||
errmsg = "you already have a newer version";
|
||||
result.appendTimestamp( "oldVersion" , oldVersion );
|
||||
result.appendTimestamp( "newVersion" , version );
|
||||
result.appendTimestamp( "globalVersion" , globalVersion );
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -68,8 +68,10 @@ namespace mongo {
|
||||
|
||||
void Strategy::insert( const Shard& shard , const char * ns , const BSONObj& obj ){
|
||||
ShardConnection dbcon( shard , ns );
|
||||
if ( dbcon.setVersion() )
|
||||
if ( dbcon.setVersion() ){
|
||||
dbcon.done();
|
||||
throw StaleConfigException( ns , "for insert" );
|
||||
}
|
||||
dbcon->insert( ns , obj );
|
||||
dbcon.done();
|
||||
}
|
||||
|
@ -274,7 +274,7 @@ ShardingTest.prototype.getChunksString = function( ns ){
|
||||
q.ns = ns;
|
||||
|
||||
var s = "";
|
||||
this.config.chunks.find( q ).sort( { min : 1 } ).forEach(
|
||||
this.config.chunks.find( q ).sort( { ns : 1 , min : 1 } ).forEach(
|
||||
function(z){
|
||||
s += " " + z._id + "\t" + z.lastmod.t + "|" + z.lastmod.i + "\t" + tojson(z.min) + " -> " + tojson(z.max) + " " + z.shard + " " + z.ns + "\n";
|
||||
}
|
||||
@ -305,6 +305,8 @@ ShardingTest.prototype.printCollectionInfo = function( ns , msg ){
|
||||
out += " mongos " + c + " " + tojson( c.getCollection( ns ).getShardVersion() , " " , true ) + "\n";
|
||||
}
|
||||
|
||||
out += this.getChunksString( ns );
|
||||
|
||||
print( out );
|
||||
}
|
||||
|
||||
@ -368,6 +370,17 @@ ShardingTest.prototype.onNumShards = function( collName , dbName ){
|
||||
return num;
|
||||
}
|
||||
|
||||
|
||||
ShardingTest.prototype.shardCounts = function( collName , dbName ){
|
||||
this.sync(); // we should sync since we're going directly to mongod here
|
||||
dbName = dbName || "test";
|
||||
var counts = {}
|
||||
for ( var i=0; i<this._connections.length; i++ )
|
||||
counts[i] = this._connections[i].getDB( dbName ).getCollection( collName ).count();
|
||||
return counts;
|
||||
}
|
||||
|
||||
|
||||
ShardingTest.prototype.shardGo = function( collName , key , split , move , dbName ){
|
||||
split = split || key;
|
||||
move = move || split;
|
||||
|
Loading…
Reference in New Issue
Block a user