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

require manual resync on filled oplog

This commit is contained in:
Aaron 2009-04-23 12:16:18 -04:00
parent 64c5d55c59
commit 8bf9e88cf1
3 changed files with 47 additions and 4 deletions

View File

@ -130,6 +130,9 @@ namespace mongo {
variables.
*/
assert( dbMutexInfo.isLocked() );
log( 5 ) << "setClient: " << ns << endl;
Top::clientStart( ns );
curNs = ns;

View File

@ -185,6 +185,24 @@ namespace mongo {
}
} cmdReplacePeer;
class CmdForceDead : public Command {
public:
virtual bool slaveOk() {
return true;
}
virtual bool adminOnly() {
return true;
}
virtual bool logTheOp() {
return false;
}
CmdForceDead() : Command("forcedead") { }
virtual bool run(const char *ns, BSONObj& cmdObj, string& errmsg, BSONObjBuilder& result, bool fromRepl) {
replAllDead = "forced by command";
return true;
}
} cmdForceDead;
class CmdResync : public Command {
public:
virtual bool slaveOk() {
@ -793,6 +811,7 @@ namespace mongo {
see logOp() comments.
*/
void ReplSource::sync_pullOpLog_applyOperation(BSONObj& op, IdSets &ids, IdSets &modIds, OpTime *localLogTail) {
log( 6 ) << "processing op: " << op << endl;
// skip no-op
if ( op.getStringField( "op" )[ 0 ] == 'n' )
return;
@ -839,6 +858,8 @@ namespace mongo {
bool incompleteClone = incompleteCloneDbs.count( clientName ) != 0;
log( 6 ) << "ns: " << ns << ", justCreated: " << justCreated << ", incompleteClone: " << incompleteClone << endl;
if ( justCreated || incompleteClone ) {
if ( incompleteClone ) {
log() << "An earlier initial clone of '" << clientName << "' did not complete, will resync." << endl;
@ -948,9 +969,8 @@ namespace mongo {
save();
cursor.reset();
}
BSONObj info;
massert( "request for slave to resync failed",
conn->runCommand( "admin", fromjson( "{resync:1,force:true}" ), info ) );
massert( "request to kill slave replication falied",
conn->simpleCommand( "admin", 0, "forcedead" ) );
}
bool ReplSource::updateSetsWithLocalOps( IdSets &ids, IdSets &modIds, OpTime &localLogTail, bool unlock ) {
@ -1016,6 +1036,7 @@ namespace mongo {
string name = e.embeddedObject().getField( "name" ).valuestr();
if ( name != "local" ) {
if ( only.empty() || only == name ) {
log( 2 ) << "adding to 'addDbNextPass': " << name << endl;
addDbNextPass.insert( name );
}
}

View File

@ -26,12 +26,27 @@ disconnect = function() {
checkCount = function( m, c ) {
m.setSlaveOk();
assert.soon( function() {
if ( -1 == m.getDBNames().indexOf( baseName ) ) {
return false;
}
if ( -1 == m.getDB( baseName ).getCollectionNames().indexOf( baseName ) ) {
return false;
}
actual = m.getDB( baseName ).getCollection( baseName ).find().count();
print( actual );
return c == actual; },
"expected count " + c + " for " + m );
}
resetSlave = function( s ) {
s.setSlaveOk();
assert.soon( function() {
ret = s.getDB( "admin" ).runCommand( { "resync" : 1 } );
// printjson( ret );
return 1 == ret.ok;
} );
}
big = new Array( 2000 ).toString();
doTest = function() {
@ -90,6 +105,8 @@ doTest = function() {
return ( lm == 0 && rm == 1 );
} );
resetSlave( l );
checkCount( l, 1 );
checkCount( r, 1 );
@ -127,7 +144,9 @@ doTest = function() {
return ( lm == 0 && rm == 1 );
} );
sleep( 30000 );
sleep( 15000 );
resetSlave( l );
checkCount( l, 1000 );
checkCount( r, 1000 );