summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDwight <dwight@10gen.com>2010-08-03 15:00:56 -0400
committerDwight <dwight@10gen.com>2010-08-03 15:00:56 -0400
commitbeaf89b124fadf8f63e2077346039880ab6eac81 (patch)
tree932e8d4b4b3d07836c809194ccb113dbff1efc2f
parentc23fc0b083ffa6e6190e2c5038d0d4c4156deb64 (diff)
downloadmongo-beaf89b124fadf8f63e2077346039880ab6eac81.tar.gz
rs rollback create collection
-rw-r--r--db/cap.cpp2
-rw-r--r--db/repl/rs_rollback.cpp29
-rw-r--r--jstests/replsets/rollback2.js3
3 files changed, 30 insertions, 4 deletions
diff --git a/db/cap.cpp b/db/cap.cpp
index 66c7064356f..c6764298075 100644
--- a/db/cap.cpp
+++ b/db/cap.cpp
@@ -300,7 +300,7 @@ namespace mongo {
}
}
- massert( 13415, "emptying the collection is not allowed", nrecords > 1 );
+ uassert( 13415, "emptying the collection is not allowed", nrecords > 1 );
if ( !capLooped() ) {
theDataFileMgr.deleteRecord(ns, curr.rec(), curr, true);
diff --git a/db/repl/rs_rollback.cpp b/db/repl/rs_rollback.cpp
index e9d8ed1945d..f5b7311691a 100644
--- a/db/repl/rs_rollback.cpp
+++ b/db/repl/rs_rollback.cpp
@@ -78,6 +78,9 @@ namespace mongo {
need to refetch it once. */
set<DocID> toRefetch;
+ /* collections to drop */
+ set<string> toDrop;
+
OpTime commonPoint;
DiskLoc commonPointOurDiskloc;
@@ -97,7 +100,7 @@ namespace mongo {
DocID d;
d.ns = ourObj.getStringField("ns");
if( *d.ns == 0 ) {
- log() << "replSet WARNING ignoring op on rollback TODO : " << ourObj.toString() << rsLog;
+ log() << "replSet WARNING ignoring op on rollback no ns TODO : " << ourObj.toString() << rsLog;
return;
}
@@ -107,6 +110,16 @@ namespace mongo {
return;
}
+ if( *op == 'c' ) {
+ /* Create collection operation
+ { ts: ..., h: ..., op: "c", ns: "foo.$cmd", o: { create: "abc", ... } }
+ */
+ NamespaceString s(d.ns); // foo.$cmd
+ string ns = s.db + '.' + o["create"].String(); // -> foo.abc
+ h.toDrop.insert(ns);
+ return;
+ }
+
d._id = o["_id"];
if( d._id.eoo() ) {
log() << "replSet WARNING ignoring op on rollback no _id TODO : " << ourObj.toString() << rsLog;
@@ -274,6 +287,20 @@ namespace mongo {
catch(...){}
Helpers::putSingleton("local.replset.minvalid", newMinValid);
+ /** first drop collections to drop - that might make things faster below actually if there were subsequent inserts */
+ for( set<string>::iterator i = h.toDrop.begin(); i != h.toDrop.end(); i++ ) {
+ Client::Context c(*i, dbpath, 0, /*doauth*/false);
+ try {
+ bob res;
+ string errmsg;
+ log(1) << "replSet rollback drop: " << *i << rsLog;
+ dropCollection(*i, errmsg, res);
+ }
+ catch(...) {
+ log() << "replset rollback error dropping collection " << *i << rsLog;
+ }
+ }
+
Client::Context c(rsoplog, dbpath, 0, /*doauth*/false);
NamespaceDetails *oplogDetails = nsdetails(rsoplog);
uassert(13423, str::stream() << "replSet error in rollback can't find " << rsoplog, oplogDetails);
diff --git a/jstests/replsets/rollback2.js b/jstests/replsets/rollback2.js
index 5817208854e..d24c5d995b2 100644
--- a/jstests/replsets/rollback2.js
+++ b/jstests/replsets/rollback2.js
@@ -97,8 +97,7 @@ function doItemsToRollBack(db) {
db.newcoll.insert({ a: true });
// create a new empty collection (need to roll back the whole thing)
- // TODO NOT DONE
- // db.createCollection("abc");
+ db.createCollection("abc");
}
function doWritesToKeep2(db) {