summaryrefslogtreecommitdiff
path: root/db/repl/rs_rollback.cpp
diff options
context:
space:
mode:
authordwight <dwight@10gen.com>2010-08-16 09:17:14 -0400
committerdwight <dwight@10gen.com>2010-08-16 09:17:14 -0400
commit23df1acdd1a39784ae18efc97c42f6337ac20b5f (patch)
treee9c981f6d7ca8fdab373d4314ddb9646de602dc7 /db/repl/rs_rollback.cpp
parentb7e8c057871f66b1e05c458e48b593521423c179 (diff)
downloadmongo-23df1acdd1a39784ae18efc97c42f6337ac20b5f.tar.gz
rs rollback work 162
Diffstat (limited to 'db/repl/rs_rollback.cpp')
-rw-r--r--db/repl/rs_rollback.cpp35
1 files changed, 30 insertions, 5 deletions
diff --git a/db/repl/rs_rollback.cpp b/db/repl/rs_rollback.cpp
index bf14dc7346d..757353c7e21 100644
--- a/db/repl/rs_rollback.cpp
+++ b/db/repl/rs_rollback.cpp
@@ -62,6 +62,11 @@ namespace mongo {
using namespace bson;
+ class rsfatal : public std::exception {
+ public:
+ virtual const char* what() const throw(){ return "replica set fatal exception"; }
+ };
+
struct DocID {
const char *ns;
be _id;
@@ -113,15 +118,21 @@ namespace mongo {
if( *op == 'c' ) {
be first = o.firstElement();
NamespaceString s(d.ns); // foo.$cmd
-
- Command *cmd = Command::findCommand( first.fieldName() );
+ string cmdname = first.fieldName();
+ Command *cmd = Command::findCommand(cmdname.c_str());
if( cmd == 0 ) {
log() << "replSet warning rollback no suchcommand " << first.fieldName() << " - different mongod versions perhaps?" << rsLog;
return;
}
else {
- /* dropdatabase, drop, reindex, dropindexes, findandmodify, godinsert?, renamecollection */
- if( string("create") == first.fieldName() ) {
+ /* dropdatabase - resync
+ drop - resync coll
+ dropindexes - refetch indexes
+ findandmodify - tranlated?
+ godinsert?,
+ renamecollection a->b. just resync a & b
+ */
+ if( cmdname == "create" ) {
/* Create collection operation
{ ts: ..., h: ..., op: "c", ns: "foo.$cmd", o: { create: "abc", ... } }
*/
@@ -129,8 +140,17 @@ namespace mongo {
h.toDrop.insert(ns);
return;
}
+ else if( cmdname == "reIndex" ) {
+ return;
+ }
+ else if( cmdname == "dropDatabase" ) {
+ log() << "replSet ERROR rollback : can't rollback drop database full resync will be required" << rsLog;
+ log() << "replSet " << o.toString() << rsLog;
+ throw rsfatal();
+ }
else {
- log() << "replSet WARNING can't roll back this command yet: " << o.toString() << rsLog;
+ log() << "replSet ERROR can't rollback this command yet: " << o.toString() << rsLog;
+ throw rsfatal();
}
}
}
@@ -499,6 +519,11 @@ namespace mongo {
sleepsecs(10);
return;
}
+ catch( rsfatal& ) {
+ _fatal();
+ sleepsecs(2);
+ return;
+ }
catch( DBException& e ) {
sethbmsg(string("syncRollback 2 exception ") + e.toString() + "; sleeping 1 min");
sleepsecs(60);