summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNathan Myers <nathan.myers@10gen.com>2017-05-16 14:47:12 -0400
committerNathan Myers <nathan.myers@10gen.com>2017-05-16 16:49:27 -0400
commit4351282737916875d039b56cc20b2e6772f2e702 (patch)
treead2ecfa503fd7ad1e791aa4e23d234e9b19d1f84
parentee3d5b711b684624da5b3d4ace1b8ee85fa19bcd (diff)
downloadmongo-4351282737916875d039b56cc20b2e6772f2e702.tar.gz
SERVER-28810 Re-try range deletions, backport to 3.4
-rw-r--r--src/mongo/db/dbhelpers.cpp32
1 files changed, 18 insertions, 14 deletions
diff --git a/src/mongo/db/dbhelpers.cpp b/src/mongo/db/dbhelpers.cpp
index 57c02cb3085..ebed6807c7e 100644
--- a/src/mongo/db/dbhelpers.cpp
+++ b/src/mongo/db/dbhelpers.cpp
@@ -37,6 +37,7 @@
#include "mongo/db/catalog/collection.h"
#include "mongo/db/catalog/index_create.h"
+#include "mongo/db/concurrency/write_conflict_exception.h"
#include "mongo/db/db.h"
#include "mongo/db/db_raii.h"
#include "mongo/db/exec/working_set_common.h"
@@ -375,8 +376,6 @@ long long Helpers::removeRange(OperationContext* txn,
verify(PlanExecutor::ADVANCED == state);
- WriteUnitOfWork wuow(txn);
-
if (onlyRemoveOrphanedDocs) {
// Do a final check in the write lock to make absolutely sure that our
// collection hasn't been modified in a way that invalidates our migration
@@ -408,20 +407,25 @@ long long Helpers::removeRange(OperationContext* txn,
}
}
- NamespaceString nss(ns);
- if (!repl::getGlobalReplicationCoordinator()->canAcceptWritesFor(nss)) {
- warning() << "stepped down from primary while deleting chunk; "
- << "orphaning data in " << ns << " in range [" << redact(min) << ", "
- << redact(max) << ")";
- return numDeleted;
- }
+ MONGO_WRITE_CONFLICT_RETRY_LOOP_BEGIN {
+ WriteUnitOfWork wuow(txn);
+ NamespaceString nss(ns);
+ if (!repl::getGlobalReplicationCoordinator()->canAcceptWritesFor(nss)) {
+ warning() << "stepped down from primary while deleting chunk; "
+ << "orphaning data in " << ns << " in range [" << redact(min) << ", "
+ << redact(max) << ")";
+ return numDeleted;
+ }
- if (callback)
- callback->goingToDelete(obj);
+ if (callback)
+ callback->goingToDelete(obj);
+
+ OpDebug* const nullOpDebug = nullptr;
+ collection->deleteDocument(txn, rloc, nullOpDebug, fromMigrate);
+ wuow.commit();
+ }
+ MONGO_WRITE_CONFLICT_RETRY_LOOP_END(txn, "delete range", ns);
- OpDebug* const nullOpDebug = nullptr;
- collection->deleteDocument(txn, rloc, nullOpDebug, fromMigrate);
- wuow.commit();
numDeleted++;
}