mirror of
https://github.com/mongodb/mongo.git
synced 2024-12-01 09:32:32 +01:00
SERVER-623 specify fastsync on both nodes to eliminate slow oplog scan by new pair master
This commit is contained in:
parent
23475ac37f
commit
241ec02cae
@ -14,23 +14,30 @@ rp.start();
|
||||
rp.waitForSteadyState();
|
||||
|
||||
big = new Array( 2000 ).toString();
|
||||
for( i = 0; i < 1000; ++i )
|
||||
rp.slave().setSlaveOk();
|
||||
for( i = 0; i < 1000; ++i ) {
|
||||
rp.master().getDB( baseName )[ baseName ].save( { _id: new ObjectId(), i: i, b: big } );
|
||||
if ( i % 250 == 249 ) {
|
||||
assert.soon( function() { return i+1 == rp.slave().getDB( baseName )[ baseName ].count(); } );
|
||||
}
|
||||
}
|
||||
|
||||
rp.master().getDB( "admin" ).runCommand( {fsync:1,lock:1} );
|
||||
leftMaster = ( rp.master().host == rp.left().host );
|
||||
rp.killNode( rp.slave() );
|
||||
if ( leftMaster ) {
|
||||
copyDbpath( basePath + "-left", basePath + "-right" );
|
||||
rp.right_.extraArgs_ = [ "--fastsync" ];
|
||||
} else {
|
||||
copyDbpath( basePath + "-right", basePath + "-left" );
|
||||
rp.left_.extraArgs_ = [ "--fastsync" ];
|
||||
}
|
||||
rp.master().getDB( "admin" ).$cmd.sys.unlock.findOne();
|
||||
assert.commandWorked( rp.master().getDB( "admin" ).runCommand( {replacepeer:1} ) );
|
||||
rp.killNode( rp.master() );
|
||||
|
||||
clearRawMongoProgramOutput();
|
||||
|
||||
rp.right_.extraArgs_ = [ "--fastsync" ];
|
||||
rp.left_.extraArgs_ = [ "--fastsync" ];
|
||||
|
||||
rp.start( true );
|
||||
rp.waitForSteadyState();
|
||||
assert.eq( 1000, rp.master().getDB( baseName )[ baseName ].count() );
|
||||
|
@ -17,7 +17,9 @@ big = new Array( 2000 ).toString();
|
||||
rp.slave().setSlaveOk();
|
||||
for( i = 0; i < 1000; ++i ) {
|
||||
rp.master().getDB( baseName )[ baseName ].save( { _id: new ObjectId(), i: i, b: big } );
|
||||
assert.soon( function() { return i+1 == rp.slave().getDB( baseName )[ baseName ].count(); } );
|
||||
if ( i % 250 == 249 ) {
|
||||
assert.soon( function() { return i+1 == rp.slave().getDB( baseName )[ baseName ].count(); } );
|
||||
}
|
||||
}
|
||||
|
||||
rp.slave().getDB( "admin" ).runCommand( {fsync:1,lock:1} );
|
||||
@ -25,15 +27,17 @@ leftSlave = ( rp.slave().host == rp.left().host );
|
||||
rp.killNode( rp.master() );
|
||||
if ( leftSlave ) {
|
||||
copyDbpath( basePath + "-left", basePath + "-right" );
|
||||
rp.right_.extraArgs_ = [ "--fastsync" ];
|
||||
} else {
|
||||
copyDbpath( basePath + "-right", basePath + "-left" );
|
||||
rp.left_.extraArgs_ = [ "--fastsync" ];
|
||||
}
|
||||
rp.slave().getDB( "admin" ).$cmd.sys.unlock.findOne();
|
||||
assert.commandWorked( rp.slave().getDB( "admin" ).runCommand( {replacepeer:1} ) );
|
||||
rp.killNode( rp.slave() );
|
||||
|
||||
clearRawMongoProgramOutput();
|
||||
|
||||
rp.right_.extraArgs_ = [ "--fastsync" ];
|
||||
rp.left_.extraArgs_ = [ "--fastsync" ];
|
||||
|
||||
rp.start( true );
|
||||
rp.waitForSteadyState();
|
||||
assert.eq( 1000, rp.master().getDB( baseName )[ baseName ].count() );
|
||||
|
@ -218,7 +218,13 @@ namespace mongo {
|
||||
out = out.substr( len - 100000, 100000 );
|
||||
return BSON( "" << out );
|
||||
}
|
||||
|
||||
|
||||
BSONObj ClearRawMongoProgramOutput( const BSONObj &args ) {
|
||||
boost::mutex::scoped_lock lk( mongoProgramOutputMutex );
|
||||
mongoProgramOutput_.str( "" );
|
||||
return undefined_;
|
||||
}
|
||||
|
||||
class ProgramRunner {
|
||||
vector<string> argv_;
|
||||
int port_;
|
||||
@ -660,6 +666,7 @@ namespace mongo {
|
||||
scope.injectNative( "stopMongoProgram", StopMongoProgram );
|
||||
scope.injectNative( "stopMongoProgramByPid", StopMongoProgramByPid );
|
||||
scope.injectNative( "rawMongoProgramOutput", RawMongoProgramOutput );
|
||||
scope.injectNative( "clearRawMongoProgramOutput", ClearRawMongoProgramOutput );
|
||||
|
||||
//can't access filesystem
|
||||
scope.injectNative( "removeFile" , removeFile );
|
||||
|
Loading…
Reference in New Issue
Block a user