mirror of
https://github.com/mongodb/mongo.git
synced 2024-12-01 09:32:32 +01:00
SERVER-1463 failing count even when oplog is up to date
This commit is contained in:
parent
39a3e9f4a1
commit
f4578edbe5
@ -59,7 +59,6 @@ doTest = function( signal ) {
|
||||
|
||||
assert( master_id != new_master_id, "Old master shouldn't be equal to new master." );
|
||||
|
||||
|
||||
{
|
||||
// this may fail since it has to reconnect
|
||||
try {
|
||||
@ -74,8 +73,44 @@ doTest = function( signal ) {
|
||||
// Here's how to restart a node:
|
||||
replTest.restart( master_id );
|
||||
|
||||
// Now let's write some documents to the new master
|
||||
for(var i=0; i<1000; i++) {
|
||||
new_master.getDB("bar").bar.save({a: i});
|
||||
}
|
||||
new_master.getDB("admin").runCommand({getlasterror: 1});
|
||||
|
||||
// Here's how to restart the old master node:
|
||||
slave = replTest.restart( master_id );
|
||||
|
||||
// Now, let's make sure that the old master comes up as a slave
|
||||
assert.soon(function() {
|
||||
var res = slave.getDB("admin").runCommand({ismaster: 1});
|
||||
printjson(res);
|
||||
return res['ok'] == 1 && res['ismaster'] == false;
|
||||
});
|
||||
|
||||
// And we need to make sure that the replset comes back up
|
||||
assert.soon(function() {
|
||||
var res = new_master.getDB("admin").runCommand({replSetGetStatus: 1});
|
||||
printjson( res );
|
||||
return res.myState == 1;
|
||||
});
|
||||
|
||||
// And that both slave nodes have all the updates
|
||||
new_master = replTest.getMaster();
|
||||
replTest.awaitReplication();
|
||||
|
||||
slaves = replTest.liveNodes.slaves;
|
||||
assert( slaves.length == 2, "Expected 2 slaves but length was " + slaves.length );
|
||||
slaves.forEach(function(slave) {
|
||||
slave.setSlaveOk();
|
||||
var count = slave.getDB("bar").runCommand({count: "bar"});
|
||||
printjson( count );
|
||||
assert( count.n == 1000 , slave + " expected 1000 but count was " + count.n);
|
||||
});
|
||||
|
||||
// Shut down the set and finish the test.
|
||||
replTest.stopSet( signal );
|
||||
}
|
||||
|
||||
doTest( 15 );
|
||||
// doTest( 15 );
|
||||
|
@ -1140,6 +1140,7 @@ ReplSetTest.prototype.awaitReplication = function() {
|
||||
this.getMaster();
|
||||
|
||||
latest = this.liveNodes.master.getDB("local")['oplog.rs'].find({}).sort({'$natural': -1}).limit(1).next()['ts']['t']
|
||||
print(latest);
|
||||
|
||||
this.attempt({context: this, timeout: 30000, desc: "awaiting replication"},
|
||||
function() {
|
||||
@ -1155,9 +1156,14 @@ ReplSetTest.prototype.awaitReplication = function() {
|
||||
}
|
||||
|
||||
slave.getDB("admin").getMongo().setSlaveOk();
|
||||
var log = slave.getDB("local")['replset.minvalid'];
|
||||
if(log.find().hasNext()) {
|
||||
synced == synced && log.find().next()['ts']['t'];
|
||||
var log = slave.getDB("local")['oplog.rs'];
|
||||
if(log.find({}).sort({'$natural': -1}).limit(1).hasNext()) {
|
||||
var entry = log.find({}).sort({'$natural': -1}).limit(1).next();
|
||||
printjson( entry );
|
||||
var ts = entry['ts']['t'];
|
||||
print("TS for " + slave + " is " + ts + " and latest is " + latest);
|
||||
print("Oplog size for " + slave + " is " + log.count());
|
||||
synced = (synced && (latest == ts));
|
||||
}
|
||||
else {
|
||||
synced = false;
|
||||
@ -1186,8 +1192,11 @@ ReplSetTest.prototype.start = function( n , options , restart ){
|
||||
|
||||
print("Starting....");
|
||||
print( o );
|
||||
if ( restart )
|
||||
return startMongoProgram.apply( null , o );
|
||||
if ( restart ) {
|
||||
this.nodes[n] = startMongoProgram.apply( null , o );
|
||||
printjson(this.nodes);
|
||||
return this.nodes[n];
|
||||
}
|
||||
else {
|
||||
return startMongod.apply( null , o );
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user