summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAaron <aaron@10gen.com>2011-03-22 21:06:54 -0700
committerAaron <aaron@10gen.com>2011-03-24 10:03:35 -0700
commit20ca858390938f916f64572bc21495b39a2db7be (patch)
treed2a9b0b8a936835f19deef9ceaa196582eb316b1
parent2394d382e194a11cd9d1194dad5321d1f59e253a (diff)
downloadmongo-20ca858390938f916f64572bc21495b39a2db7be.tar.gz
SERVER-2737 commitIfNeeded() in cappedTruncateAfter()
-rw-r--r--db/cap.cpp1
-rw-r--r--jstests/slowWeekly/rollback4.js50
2 files changed, 51 insertions, 0 deletions
diff --git a/db/cap.cpp b/db/cap.cpp
index 198bd541970..260b311eec8 100644
--- a/db/cap.cpp
+++ b/db/cap.cpp
@@ -319,6 +319,7 @@ namespace mongo {
// 'end' has been found and removed, so break.
break;
}
+ getDur().commitIfNeeded();
// 'curr' will point to the newest document in the collection.
DiskLoc curr = theCapExtent()->lastRecord;
assert( !curr.isNull() );
diff --git a/jstests/slowWeekly/rollback4.js b/jstests/slowWeekly/rollback4.js
new file mode 100644
index 00000000000..968980deec4
--- /dev/null
+++ b/jstests/slowWeekly/rollback4.js
@@ -0,0 +1,50 @@
+// Test a large rollback SERVER-2737
+
+var replTest = new ReplSetTest({ name: 'unicomplex', nodes: 3, oplogSize: 2000 });
+var nodes = replTest.nodeList();
+
+var conns = replTest.startSet();
+var r = replTest.initiate({ "_id": "unicomplex",
+ "members": [
+ { "_id": 0, "host": nodes[0] },
+ { "_id": 1, "host": nodes[1] },
+ { "_id": 2, "host": nodes[2], arbiterOnly: true}]
+ });
+
+// Make sure we have a master
+var master = replTest.getMaster();
+b_conn = conns[1];
+b_conn.setSlaveOk();
+B = b_conn.getDB("admin");
+
+// Make sure we have an arbiter
+assert.soon(function () {
+ res = conns[2].getDB("admin").runCommand({ replSetGetStatus: 1 });
+ return res.myState == 7;
+ }, "Arbiter failed to initialize.");
+
+// Wait for initial replication
+replTest.awaitReplication();
+
+// Insert into master
+var big = { b:new Array( 1000 ).toString() };
+for( var i = 0; i < 1000000; ++i ) {
+ if ( i % 10000 == 0 ) {
+ print( i );
+ }
+ master.getDB( 'db' ).c.insert( big );
+}
+
+// Stop master
+replTest.stop( 0 );
+
+// Wait for slave to take over
+assert.soon(function () { return B.isMaster().ismaster; });
+master = replTest.getMaster();
+
+// Save to new master, forcing rollback of old master
+master.getDB( 'db' ).c.save( big );
+
+// Restart old master
+replTest.restart( 0 );
+replTest.awaitReplication();