summaryrefslogtreecommitdiff
path: root/src/mongo/db/repl/rs_rollback.cpp
diff options
context:
space:
mode:
authorKyle Suarez <kyle.suarez@mongodb.com>2018-03-07 13:47:50 -0500
committerKyle Suarez <kyle.suarez@mongodb.com>2018-03-07 13:47:50 -0500
commit86e1b61020ebe8c9490bce56b26b8037581a9c72 (patch)
tree06a8f80fedc62174ea87ec4ae4090f2230ecff93 /src/mongo/db/repl/rs_rollback.cpp
parent905194e3afac93289be65b40ede265e8fbfda6a4 (diff)
downloadmongo-86e1b61020ebe8c9490bce56b26b8037581a9c72.tar.gz
SERVER-33663 create parameter to control rollback data file creation
Users can suppress the creation of rollback data files by setting the 'createRollbackDataFiles' setParameter to false.
Diffstat (limited to 'src/mongo/db/repl/rs_rollback.cpp')
-rw-r--r--src/mongo/db/repl/rs_rollback.cpp80
1 files changed, 42 insertions, 38 deletions
diff --git a/src/mongo/db/repl/rs_rollback.cpp b/src/mongo/db/repl/rs_rollback.cpp
index 4d4be47675f..7be60a07c4f 100644
--- a/src/mongo/db/repl/rs_rollback.cpp
+++ b/src/mongo/db/repl/rs_rollback.cpp
@@ -743,45 +743,47 @@ void dropCollection(OperationContext* opCtx,
NamespaceString nss,
Collection* collection,
Database* db) {
- Helpers::RemoveSaver removeSaver("rollback", "", nss.ns());
-
- // Performs a collection scan and writes all documents in the collection to disk
- // in order to keep an archive of items that were rolled back.
- auto exec = InternalPlanner::collectionScan(
- opCtx, nss.toString(), collection, PlanExecutor::YIELD_AUTO);
- BSONObj curObj;
- PlanExecutor::ExecState execState;
- while (PlanExecutor::ADVANCED == (execState = exec->getNext(&curObj, NULL))) {
- auto status = removeSaver.goingToDelete(curObj);
- if (!status.isOK()) {
- severe() << "Rolling back createCollection on " << nss
- << " failed to write document to remove saver file: " << redact(status);
- throw RSFatalException(
- "Rolling back createCollection. Failed to write document to remove saver "
- "file.");
+ if (RollbackImpl::shouldCreateDataFiles()) {
+ Helpers::RemoveSaver removeSaver("rollback", "", nss.ns());
+
+ // Performs a collection scan and writes all documents in the collection to disk
+ // in order to keep an archive of items that were rolled back.
+ auto exec = InternalPlanner::collectionScan(
+ opCtx, nss.toString(), collection, PlanExecutor::YIELD_AUTO);
+ BSONObj curObj;
+ PlanExecutor::ExecState execState;
+ while (PlanExecutor::ADVANCED == (execState = exec->getNext(&curObj, NULL))) {
+ auto status = removeSaver.goingToDelete(curObj);
+ if (!status.isOK()) {
+ severe() << "Rolling back createCollection on " << nss
+ << " failed to write document to remove saver file: " << redact(status);
+ throw RSFatalException(
+ "Rolling back createCollection. Failed to write document to remove saver "
+ "file.");
+ }
}
- }
- // If we exited the above for loop with any other execState than IS_EOF, this means that
- // a FAILURE or DEAD state was returned. If a DEAD state occurred, the collection or
- // database that we are attempting to save may no longer be valid. If a FAILURE state
- // was returned, either an unrecoverable error was thrown by exec, or we attempted to
- // retrieve data that could not be provided by the PlanExecutor. In both of these cases
- // it is necessary for a full resync of the server.
-
- if (execState != PlanExecutor::IS_EOF) {
- if (execState == PlanExecutor::FAILURE &&
- WorkingSetCommon::isValidStatusMemberObject(curObj)) {
- Status errorStatus = WorkingSetCommon::getMemberObjectStatus(curObj);
- severe() << "Rolling back createCollection on " << nss << " failed with "
- << redact(errorStatus) << ". A full resync is necessary.";
- throw RSFatalException(
- "Rolling back createCollection failed. A full resync is necessary.");
- } else {
- severe() << "Rolling back createCollection on " << nss
- << " failed. A full resync is necessary.";
- throw RSFatalException(
- "Rolling back createCollection failed. A full resync is necessary.");
+ // If we exited the above for loop with any other execState than IS_EOF, this means that
+ // a FAILURE or DEAD state was returned. If a DEAD state occurred, the collection or
+ // database that we are attempting to save may no longer be valid. If a FAILURE state
+ // was returned, either an unrecoverable error was thrown by exec, or we attempted to
+ // retrieve data that could not be provided by the PlanExecutor. In both of these cases
+ // it is necessary for a full resync of the server.
+
+ if (execState != PlanExecutor::IS_EOF) {
+ if (execState == PlanExecutor::FAILURE &&
+ WorkingSetCommon::isValidStatusMemberObject(curObj)) {
+ Status errorStatus = WorkingSetCommon::getMemberObjectStatus(curObj);
+ severe() << "Rolling back createCollection on " << nss << " failed with "
+ << redact(errorStatus) << ". A full resync is necessary.";
+ throw RSFatalException(
+ "Rolling back createCollection failed. A full resync is necessary.");
+ } else {
+ severe() << "Rolling back createCollection on " << nss
+ << " failed. A full resync is necessary.";
+ throw RSFatalException(
+ "Rolling back createCollection failed. A full resync is necessary.");
+ }
}
}
@@ -1254,7 +1256,9 @@ void rollback_internal::syncFixUp(OperationContext* opCtx,
NamespaceString nss = catalog.lookupNSSByUUID(uuid);
- removeSaver.reset(new Helpers::RemoveSaver("rollback", "", nss.ns()));
+ if (RollbackImpl::shouldCreateDataFiles()) {
+ removeSaver = std::make_unique<Helpers::RemoveSaver>("rollback", "", nss.ns());
+ }
const auto& goodVersionsByDocID = nsAndGoodVersionsByDocID.second;
for (const auto& idAndDoc : goodVersionsByDocID) {