summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormatt dannenberg <matt.dannenberg@10gen.com>2015-04-28 08:55:15 -0400
committerRamon Fernandez <ramon@mongodb.com>2015-04-29 16:35:10 -0400
commit998f82764ec8c52a1c478623c0f1e2e61b692ab5 (patch)
treef8b538238acd4a0a38e4c6f81df178b188456501
parentab323b2f6607f265352b68c7efea971d54007207 (diff)
downloadmongo-998f82764ec8c52a1c478623c0f1e2e61b692ab5.tar.gz
SERVER-18211 write to disk all documents in a collection when rolling back createCollection
(cherry picked from commit aa54b581e9afaf7444846a35bbd1adc8262d1330)
-rw-r--r--src/mongo/db/repl/rs_rollback.cpp36
1 files changed, 34 insertions, 2 deletions
diff --git a/src/mongo/db/repl/rs_rollback.cpp b/src/mongo/db/repl/rs_rollback.cpp
index 84454b7c66d..e411d7b8573 100644
--- a/src/mongo/db/repl/rs_rollback.cpp
+++ b/src/mongo/db/repl/rs_rollback.cpp
@@ -41,6 +41,7 @@
#include "mongo/db/cloner.h"
#include "mongo/db/commands.h"
#include "mongo/db/dbhelpers.h"
+#include "mongo/db/exec/working_set_common.h"
#include "mongo/db/operation_context_impl.h"
#include "mongo/db/ops/delete.h"
#include "mongo/db/ops/update.h"
@@ -522,6 +523,8 @@ namespace {
log() << "rollback 4.3";
}
+ map<string,shared_ptr<Helpers::RemoveSaver> > removeSavers;
+
log() << "rollback 4.6";
// drop collections to drop before doing individual fixups - that might make things faster
// below actually if there were subsequent inserts to rollback
@@ -533,6 +536,37 @@ namespace {
Database* db = dbHolder().get(txn, nsToDatabaseSubstring(*it));
if (db) {
WriteUnitOfWork wunit(txn);
+
+ shared_ptr<Helpers::RemoveSaver>& removeSaver = removeSavers[*it];
+ if (!removeSaver)
+ removeSaver.reset(new Helpers::RemoveSaver("rollback", "", *it));
+
+ // perform a collection scan and write all documents in the collection to disk
+ boost::scoped_ptr<PlanExecutor> exec(
+ InternalPlanner::collectionScan(txn,
+ *it,
+ db->getCollection(*it)));
+ BSONObj curObj;
+ PlanExecutor::ExecState execState;
+ while (PlanExecutor::ADVANCED == (execState = exec->getNext(&curObj, NULL))) {
+ removeSaver->goingToDelete(curObj);
+ }
+ if (execState != PlanExecutor::IS_EOF) {
+ if (execState == PlanExecutor::FAILURE &&
+ WorkingSetCommon::isValidStatusMemberObject(curObj)) {
+ Status errorStatus = WorkingSetCommon::getMemberObjectStatus(curObj);
+ severe() << "rolling back createCollection on " << *it
+ << " failed with " << errorStatus
+ << ". A full resync is necessary.";
+ }
+ else {
+ severe() << "rolling back createCollection on " << *it
+ << " failed. A full resync is necessary.";
+ }
+
+ throw RSFatalException();
+ }
+
db->dropCollection(txn, *it);
wunit.commit();
}
@@ -545,8 +579,6 @@ namespace {
str::stream() << "replSet error in rollback can't find " << rsoplog,
oplogCollection);
- map<string,shared_ptr<Helpers::RemoveSaver> > removeSavers;
-
unsigned deletes = 0, updates = 0;
time_t lastProgressUpdate = time(0);
time_t progressUpdateGap = 10;