diff options
author | Louis Williams <louis.williams@mongodb.com> | 2020-04-10 10:02:34 -0400 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2020-04-10 14:16:22 +0000 |
commit | 3d929ed533a72446353b18b5d60770aed33b58f1 (patch) | |
tree | 09bd3562511aef88eb6aa1ef3b6c45b8d73c16e9 /src/mongo/db/catalog/drop_database.cpp | |
parent | 76d4548a751a56c8faf1887114685b540203a650 (diff) | |
download | mongo-3d929ed533a72446353b18b5d60770aed33b58f1.tar.gz |
SERVER-46560 Make abort index build deterministic
This redesigns user index build abort to have the following behavior:
- Take a collection X lock to stop the index build from making progress
- If we are no longer primary, return an error
- Check whether we can abort the index build (i.e. it is not already committing
or aborting)
- Delete the index catalog entry and write the abortIndexBuild oplog entry in a WUOW
- Interrupt the index builder thread
- Wait for the thread to exit
- Release locks
Diffstat (limited to 'src/mongo/db/catalog/drop_database.cpp')
-rw-r--r-- | src/mongo/db/catalog/drop_database.cpp | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/src/mongo/db/catalog/drop_database.cpp b/src/mongo/db/catalog/drop_database.cpp index 5e0f097bc3f..8a50570b765 100644 --- a/src/mongo/db/catalog/drop_database.cpp +++ b/src/mongo/db/catalog/drop_database.cpp @@ -176,10 +176,6 @@ Status _dropDatabase(OperationContext* opCtx, const std::string& dbName, bool ab // We need to keep aborting all the active index builders for this database until there // are none left when we retrieve the exclusive database lock again. while (indexBuildsCoord->inProgForDb(dbName)) { - // Sends the abort signal to all the active index builders for this database. - indexBuildsCoord->abortDatabaseIndexBuildsNoWait( - opCtx, dbName, "dropDatabase command"); - // Create a scope guard to reset the drop-pending state on the database to false if // there is a replica state change that kills this operation while the locks were // yielded. @@ -192,12 +188,12 @@ Status _dropDatabase(OperationContext* opCtx, const std::string& dbName, bool ab dropPendingGuard.dismiss(); }); - // Now that the abort signals were sent out to the active index builders for this - // database, we need to release the lock temporarily to allow those index builders - // to process the abort signal. Holding a lock here will cause the index builders to - // block indefinitely. + // Drop locks. The drop helper will acquire locks on our behalf. autoDB = boost::none; - indexBuildsCoord->awaitNoBgOpInProgForDb(opCtx, dbName); + + // Sends the abort signal to all the active index builders for this database. Waits + // for aborted index builds to complete. + indexBuildsCoord->abortDatabaseIndexBuilds(opCtx, dbName, "dropDatabase command"); if (MONGO_unlikely(dropDatabaseHangAfterWaitingForIndexBuilds.shouldFail())) { LOGV2(4612300, |