summaryrefslogtreecommitdiff
path: root/src/mongo/db
diff options
context:
space:
mode:
authorBenety Goh <benety@mongodb.com>2019-08-22 12:59:14 -0400
committerBenety Goh <benety@mongodb.com>2019-08-27 20:14:20 -0400
commitbf41d49a77695d50479aa37902a4e622a01bc37f (patch)
treec8bafaa4a5626e1ffe8760fb146c68cd3471f807 /src/mongo/db
parent539368137060c637f5e373a341a1d09813c1d403 (diff)
downloadmongo-bf41d49a77695d50479aa37902a4e622a01bc37f.tar.gz
SERVER-42799 obtain timestamp for cleaning up index build without noop write
(cherry picked from commit 283e8966d1b24559963c460591b1cb845e4c6f9a)
Diffstat (limited to 'src/mongo/db')
-rw-r--r--src/mongo/db/catalog/multi_index_block.cpp19
1 files changed, 4 insertions, 15 deletions
diff --git a/src/mongo/db/catalog/multi_index_block.cpp b/src/mongo/db/catalog/multi_index_block.cpp
index 920f6773f83..f5e0da75b28 100644
--- a/src/mongo/db/catalog/multi_index_block.cpp
+++ b/src/mongo/db/catalog/multi_index_block.cpp
@@ -119,7 +119,6 @@ void MultiIndexBlock::cleanUpAfterBuild(OperationContext* opCtx, Collection* col
_indexes[i].block->deleteTemporaryTables(opCtx);
}
- auto replCoord = repl::ReplicationCoordinator::get(opCtx);
// Nodes building an index on behalf of a user (e.g: `createIndexes`, `applyOps`) may
// fail, removing the existence of the index from the catalog. This update must be
// timestamped (unless the build is on an unreplicated collection). A failure from
@@ -129,20 +128,10 @@ void MultiIndexBlock::cleanUpAfterBuild(OperationContext* opCtx, Collection* col
// We must choose a timestamp to write with, as we don't have one handy in the
// recovery unit already.
- // We need to avoid checking replication state if we do not hold the RSTL. If we do
- // not hold the RSTL, we must be a build started on a secondary via replication.
- if (opCtx->lockState()->isRSTLLocked() &&
- replCoord->canAcceptWritesForDatabase(opCtx, "admin")) {
- opCtx->getServiceContext()->getOpObserver()->onOpMessage(
- opCtx,
- BSON("msg" << std::string(str::stream()
- << "Failing index builds. Coll: " << nss)));
- } else {
- // Simply get a timestamp to write with here; we can't write to the oplog.
- repl::UnreplicatedWritesBlock uwb(opCtx);
- if (!IndexTimestampHelper::setGhostCommitTimestampForCatalogWrite(opCtx, nss)) {
- log() << "Did not timestamp index abort write.";
- }
+ // Simply get a timestamp to write with here; we can't write to the oplog.
+ repl::UnreplicatedWritesBlock uwb(opCtx);
+ if (!IndexTimestampHelper::setGhostCommitTimestampForCatalogWrite(opCtx, nss)) {
+ log() << "Did not timestamp index abort write.";
}
}
wunit.commit();