summaryrefslogtreecommitdiff
path: root/src/mongo
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo')
-rw-r--r--src/mongo/db/index_build_entry_helpers.cpp4
-rw-r--r--src/mongo/db/index_build_entry_helpers.h5
-rw-r--r--src/mongo/db/index_build_entry_helpers_test.cpp4
-rw-r--r--src/mongo/db/index_builds_coordinator.cpp23
-rw-r--r--src/mongo/db/index_builds_coordinator.h2
5 files changed, 28 insertions, 10 deletions
diff --git a/src/mongo/db/index_build_entry_helpers.cpp b/src/mongo/db/index_build_entry_helpers.cpp
index a3374a2e7b7..a72482e00ab 100644
--- a/src/mongo/db/index_build_entry_helpers.cpp
+++ b/src/mongo/db/index_build_entry_helpers.cpp
@@ -245,7 +245,9 @@ Status addIndexBuildEntry(OperationContext* opCtx, const IndexBuildEntry& indexB
});
}
-Status removeIndexBuildEntry(OperationContext* opCtx, UUID indexBuildUUID) {
+Status removeIndexBuildEntry(OperationContext* opCtx,
+ const CollectionPtr& collectionUnused,
+ UUID indexBuildUUID) {
return writeConflictRetry(
opCtx,
"removeIndexBuildEntry",
diff --git a/src/mongo/db/index_build_entry_helpers.h b/src/mongo/db/index_build_entry_helpers.h
index 594ad6ee8e4..454c88b6214 100644
--- a/src/mongo/db/index_build_entry_helpers.h
+++ b/src/mongo/db/index_build_entry_helpers.h
@@ -34,6 +34,7 @@
namespace mongo {
class IndexBuildEntry;
+class CollectionPtr;
class CommitQuorumOptions;
class OperationContext;
class Status;
@@ -105,7 +106,9 @@ Status addIndexBuildEntry(OperationContext* opCtx, const IndexBuildEntry& indexB
*
* Returns 'NoMatchingDocument' error code if no document with 'indexBuildUUID' is found.
*/
-Status removeIndexBuildEntry(OperationContext* opCtx, UUID indexBuildUUID);
+Status removeIndexBuildEntry(OperationContext* opCtx,
+ const CollectionPtr& collection,
+ UUID indexBuildUUID);
/**
* Returns the IndexBuildEntry matching the document with 'indexBuildUUID' from the disk if it
diff --git a/src/mongo/db/index_build_entry_helpers_test.cpp b/src/mongo/db/index_build_entry_helpers_test.cpp
index 336819298fd..e44e7b780dd 100644
--- a/src/mongo/db/index_build_entry_helpers_test.cpp
+++ b/src/mongo/db/index_build_entry_helpers_test.cpp
@@ -89,6 +89,10 @@ void checkIfEqual(IndexBuildEntry lhs, IndexBuildEntry rhs) {
}
}
+Status removeIndexBuildEntry(OperationContext* opCtx, UUID indexBuildUUID) {
+ return indexbuildentryhelpers::removeIndexBuildEntry(opCtx, {}, indexBuildUUID);
+}
+
class IndexBuildEntryHelpersTest : public CatalogTestFixture {
public:
void setUp() {
diff --git a/src/mongo/db/index_builds_coordinator.cpp b/src/mongo/db/index_builds_coordinator.cpp
index d211e79f5e5..89eaab16adf 100644
--- a/src/mongo/db/index_builds_coordinator.cpp
+++ b/src/mongo/db/index_builds_coordinator.cpp
@@ -167,6 +167,7 @@ bool shouldBuildIndexesOnEmptyCollectionSinglePhased(OperationContext* opCtx,
*/
void removeIndexBuildEntryAfterCommitOrAbort(OperationContext* opCtx,
const NamespaceStringOrUUID& dbAndUUID,
+ const CollectionPtr& indexBuildEntryCollection,
const ReplIndexBuildState& replState) {
if (IndexBuildProtocol::kSinglePhase == replState.protocol) {
return;
@@ -177,7 +178,8 @@ void removeIndexBuildEntryAfterCommitOrAbort(OperationContext* opCtx,
return;
}
- auto status = indexbuildentryhelpers::removeIndexBuildEntry(opCtx, replState.buildUUID);
+ auto status = indexbuildentryhelpers::removeIndexBuildEntry(
+ opCtx, indexBuildEntryCollection, replState.buildUUID);
// If we fail to remove the document from config.system.indexBuilds, it is because the document
// or collection is missing. In any case, we do not need to fail the commit or abort operation.
@@ -1149,7 +1151,8 @@ bool IndexBuildsCoordinator::abortIndexBuildByBuildUUID(OperationContext* opCtx,
// we must perform these final writes, but we expect them not to block, we can safely,
// temporarily disable interrupts.
UninterruptibleLockGuard noInterrupt(opCtx->lockState());
- _completeAbort(opCtx, replState, signalAction, {ErrorCodes::IndexBuildAborted, reason});
+ _completeAbort(
+ opCtx, replState, {}, signalAction, {ErrorCodes::IndexBuildAborted, reason});
} catch (const DBException& e) {
LOGV2_FATAL(
4656011,
@@ -1190,6 +1193,7 @@ bool IndexBuildsCoordinator::abortIndexBuildByBuildUUID(OperationContext* opCtx,
void IndexBuildsCoordinator::_completeAbort(OperationContext* opCtx,
std::shared_ptr<ReplIndexBuildState> replState,
+ const CollectionPtr& indexBuildEntryCollection,
IndexBuildAction signalAction,
Status reason) {
CollectionWriter coll(opCtx, replState->collectionUUID);
@@ -1211,7 +1215,8 @@ void IndexBuildsCoordinator::_completeAbort(OperationContext* opCtx,
<< (IndexBuildProtocol::kSinglePhase == replState->protocol));
auto onCleanUpFn = [&] { onAbortIndexBuild(opCtx, coll->ns(), *replState, reason); };
_indexBuildsManager.abortIndexBuild(opCtx, coll, replState->buildUUID, onCleanUpFn);
- removeIndexBuildEntryAfterCommitOrAbort(opCtx, dbAndUUID, *replState);
+ removeIndexBuildEntryAfterCommitOrAbort(
+ opCtx, dbAndUUID, indexBuildEntryCollection, *replState);
break;
}
// Deletes the index from the durable catalog.
@@ -1258,8 +1263,10 @@ void IndexBuildsCoordinator::_completeAbort(OperationContext* opCtx,
void IndexBuildsCoordinator::_completeSelfAbort(OperationContext* opCtx,
std::shared_ptr<ReplIndexBuildState> replState,
+ const CollectionPtr& indexBuildEntryCollection,
Status reason) {
- _completeAbort(opCtx, replState, IndexBuildAction::kPrimaryAbort, reason);
+ _completeAbort(
+ opCtx, replState, indexBuildEntryCollection, IndexBuildAction::kPrimaryAbort, reason);
replState->abortSelf(opCtx);
activeIndexBuilds.unregisterIndexBuild(&_indexBuildsManager, replState);
@@ -2033,7 +2040,7 @@ void IndexBuildsCoordinator::_cleanUpSinglePhaseAfterFailure(
const NamespaceStringOrUUID dbAndUUID(replState->dbName, replState->collectionUUID);
Lock::CollectionLock collLock(abortCtx, dbAndUUID, MODE_X);
- _completeSelfAbort(abortCtx, replState, status);
+ _completeSelfAbort(abortCtx, replState, {}, status);
});
}
@@ -2072,7 +2079,7 @@ void IndexBuildsCoordinator::_cleanUpTwoPhaseAfterFailure(
}
Lock::CollectionLock collLock(abortCtx, dbAndUUID, MODE_X);
- _completeSelfAbort(abortCtx, replState, status);
+ _completeSelfAbort(abortCtx, replState, {}, status);
});
}
@@ -2609,11 +2616,11 @@ IndexBuildsCoordinator::CommitResult IndexBuildsCoordinator::_insertKeysFromSide
// This index build failed due to an indexing error in normal circumstances. Abort while
// still holding the RSTL and collection locks.
- _completeSelfAbort(opCtx, replState, status);
+ _completeSelfAbort(opCtx, replState, {}, status);
throw;
}
- removeIndexBuildEntryAfterCommitOrAbort(opCtx, dbAndUUID, *replState);
+ removeIndexBuildEntryAfterCommitOrAbort(opCtx, dbAndUUID, {}, *replState);
replState->stats.numIndexesAfter = getNumIndexesTotal(opCtx, collection.get());
LOGV2(20663,
"Index build: completed successfully",
diff --git a/src/mongo/db/index_builds_coordinator.h b/src/mongo/db/index_builds_coordinator.h
index a899477ca17..2a8c584c201 100644
--- a/src/mongo/db/index_builds_coordinator.h
+++ b/src/mongo/db/index_builds_coordinator.h
@@ -591,10 +591,12 @@ protected:
*/
void _completeAbort(OperationContext* opCtx,
std::shared_ptr<ReplIndexBuildState> replState,
+ const CollectionPtr& indexBuildEntryCollection,
IndexBuildAction signalAction,
Status reason);
void _completeSelfAbort(OperationContext* opCtx,
std::shared_ptr<ReplIndexBuildState> replState,
+ const CollectionPtr& indexBuildEntryCollection,
Status reason);
void _completeAbortForShutdown(OperationContext* opCtx,
std::shared_ptr<ReplIndexBuildState> replState,