summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenety Goh <benety@mongodb.com>2020-02-14 18:50:51 -0500
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2020-02-15 00:03:44 +0000
commit3c4dc6da82c595834719ac00f6fdfa22deffcb83 (patch)
tree988f5b32ee260230ee7829c8bbedc2e1d24ede5d
parent98042804dff69afac74a7e2681efc0d00d207f2c (diff)
downloadmongo-3c4dc6da82c595834719ac00f6fdfa22deffcb83.tar.gz
SERVER-45885 IndexBuildsCoordinator::_waitForCommitOrAbort() checks secondary state using collection UUID
-rw-r--r--src/mongo/db/index_builds_coordinator.cpp10
-rw-r--r--src/mongo/db/index_builds_coordinator.h1
2 files changed, 4 insertions, 7 deletions
diff --git a/src/mongo/db/index_builds_coordinator.cpp b/src/mongo/db/index_builds_coordinator.cpp
index 227306126a3..eddf6bfd5c6 100644
--- a/src/mongo/db/index_builds_coordinator.cpp
+++ b/src/mongo/db/index_builds_coordinator.cpp
@@ -1700,12 +1700,11 @@ void IndexBuildsCoordinator::_buildIndexTwoPhase(
const IndexBuildOptions& indexBuildOptions,
boost::optional<Lock::CollectionLock>* exclusiveCollectionLock) {
- auto nss = *CollectionCatalog::get(opCtx).lookupNSSByUUID(opCtx, replState->collectionUUID);
auto preAbortStatus = Status::OK();
try {
_scanCollectionAndInsertKeysIntoSorter(
opCtx, dbAndUUID, replState, exclusiveCollectionLock);
- nss = _insertKeysFromSideTablesWithoutBlockingWrites(opCtx, dbAndUUID, replState);
+ _insertKeysFromSideTablesWithoutBlockingWrites(opCtx, dbAndUUID, replState);
} catch (DBException& ex) {
// Locks may no longer be held when we are interrupted. We should return immediately and, in
// the case of a primary index build, signal downstream nodes to abort via the
@@ -1715,8 +1714,8 @@ void IndexBuildsCoordinator::_buildIndexTwoPhase(
throw;
}
auto replCoord = repl::ReplicationCoordinator::get(opCtx);
- auto replSetAndNotPrimary =
- replCoord->getSettings().usingReplSets() && !replCoord->canAcceptWritesFor(opCtx, nss);
+ auto replSetAndNotPrimary = replCoord->getSettings().usingReplSets() &&
+ !replCoord->canAcceptWritesFor(opCtx, dbAndUUID);
if (!replSetAndNotPrimary) {
throw;
}
@@ -1728,7 +1727,7 @@ void IndexBuildsCoordinator::_buildIndexTwoPhase(
preAbortStatus = ex.toStatus();
}
- auto commitIndexBuildTimestamp = _waitForCommitOrAbort(opCtx, nss, replState, preAbortStatus);
+ auto commitIndexBuildTimestamp = _waitForCommitOrAbort(opCtx, replState, preAbortStatus);
_insertKeysFromSideTablesAndCommit(opCtx,
dbAndUUID,
replState,
@@ -1839,7 +1838,6 @@ NamespaceString IndexBuildsCoordinator::_insertKeysFromSideTablesWithoutBlocking
*/
Timestamp IndexBuildsCoordinator::_waitForCommitOrAbort(
OperationContext* opCtx,
- const NamespaceString& nss,
std::shared_ptr<ReplIndexBuildState> replState,
const Status& preAbortStatus) {
Timestamp commitIndexBuildTimestamp;
diff --git a/src/mongo/db/index_builds_coordinator.h b/src/mongo/db/index_builds_coordinator.h
index 144887d8633..69f34bdc924 100644
--- a/src/mongo/db/index_builds_coordinator.h
+++ b/src/mongo/db/index_builds_coordinator.h
@@ -602,7 +602,6 @@ protected:
* the index build.
*/
Timestamp _waitForCommitOrAbort(OperationContext* opCtx,
- const NamespaceString& nss,
std::shared_ptr<ReplIndexBuildState> replState,
const Status& preAbortStatus);