diff options
author | Nathan Myers <nathan.myers@10gen.com> | 2017-05-16 14:47:12 -0400 |
---|---|---|
committer | Nathan Myers <nathan.myers@10gen.com> | 2017-05-16 16:49:27 -0400 |
commit | 4351282737916875d039b56cc20b2e6772f2e702 (patch) | |
tree | ad2ecfa503fd7ad1e791aa4e23d234e9b19d1f84 /src | |
parent | ee3d5b711b684624da5b3d4ace1b8ee85fa19bcd (diff) | |
download | mongo-4351282737916875d039b56cc20b2e6772f2e702.tar.gz |
SERVER-28810 Re-try range deletions, backport to 3.4
Diffstat (limited to 'src')
-rw-r--r-- | src/mongo/db/dbhelpers.cpp | 32 |
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++; } |