summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenety Goh <benety@mongodb.com>2020-02-14 17:13:07 -0500
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2020-02-14 22:27:38 +0000
commit53c9e11517caa166183f259e0f29f87d37243c6e (patch)
treef7fec251853a63b5dc0cfec7e7d3ae74217fedd4
parent18c433f05f6b71d4e1a8ce9e1f35c8b8302ff8f3 (diff)
downloadmongo-53c9e11517caa166183f259e0f29f87d37243c6e.tar.gz
SERVER-45885 IndexBuildsCoordinator::shouldWaitForCommitOrAbort() checks secondary state using collection UUID
-rw-r--r--src/mongo/db/index_builds_coordinator.cpp9
1 files changed, 4 insertions, 5 deletions
diff --git a/src/mongo/db/index_builds_coordinator.cpp b/src/mongo/db/index_builds_coordinator.cpp
index 629ccf6b2d3..227306126a3 100644
--- a/src/mongo/db/index_builds_coordinator.cpp
+++ b/src/mongo/db/index_builds_coordinator.cpp
@@ -139,9 +139,7 @@ bool shouldBuildIndexesOnEmptyCollectionSinglePhased(OperationContext* opCtx,
* Returns true if we should wait for a commitIndexBuild or abortIndexBuild oplog entry during oplog
* application.
*/
-bool shouldWaitForCommitOrAbort(OperationContext* opCtx,
- const NamespaceString& nss,
- const ReplIndexBuildState& replState) {
+bool shouldWaitForCommitOrAbort(OperationContext* opCtx, const ReplIndexBuildState& replState) {
if (IndexBuildProtocol::kTwoPhase != replState.protocol) {
return false;
}
@@ -151,7 +149,8 @@ bool shouldWaitForCommitOrAbort(OperationContext* opCtx,
return false;
}
- if (replCoord->canAcceptWritesFor(opCtx, nss)) {
+ const NamespaceStringOrUUID dbAndUUID(replState.dbName, replState.collectionUUID);
+ if (replCoord->canAcceptWritesFor(opCtx, dbAndUUID)) {
return false;
}
@@ -1844,7 +1843,7 @@ Timestamp IndexBuildsCoordinator::_waitForCommitOrAbort(
std::shared_ptr<ReplIndexBuildState> replState,
const Status& preAbortStatus) {
Timestamp commitIndexBuildTimestamp;
- if (shouldWaitForCommitOrAbort(opCtx, nss, *replState)) {
+ if (shouldWaitForCommitOrAbort(opCtx, *replState)) {
LOGV2(20668,
"Index build waiting for commit or abort before completing final phase: "
"{replState_buildUUID}",