summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLingzhi Deng <lingzhi.deng@mongodb.com>2021-05-10 17:52:03 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2021-05-10 20:02:51 +0000
commitbd9cbc9a6a8d192895298133c2d3f65c00545617 (patch)
tree225d3b2e919b249f2f182c7ba78126872267a9e3
parent084572422d66ed815bddd792af40698eaafa2b7c (diff)
downloadmongo-bd9cbc9a6a8d192895298133c2d3f65c00545617.tar.gz
SERVER-56783: Ignore NamespaceNotFound for createIndex in tenant oplog applier
(cherry picked from commit 8f87828a42fbe05df15265eda5a0835772169f16)
-rw-r--r--src/mongo/db/repl/tenant_oplog_applier.cpp33
1 files changed, 18 insertions, 15 deletions
diff --git a/src/mongo/db/repl/tenant_oplog_applier.cpp b/src/mongo/db/repl/tenant_oplog_applier.cpp
index 44db0b4f06b..a5330eb1aa2 100644
--- a/src/mongo/db/repl/tenant_oplog_applier.cpp
+++ b/src/mongo/db/repl/tenant_oplog_applier.cpp
@@ -921,24 +921,27 @@ Status TenantOplogApplier::_applyOplogEntryOrGroupedInserts(
if (op.getCommandType() == OplogEntry::CommandType::kCreateIndexes) {
auto uuid = op.getUuid();
uassert(5652700, "Missing UUID from createIndex oplog entry", uuid);
- AutoGetCollectionForRead autoColl(opCtx, {op.getNss().db().toString(), *uuid});
- if (!autoColl.getCollection()) {
+ try {
+ AutoGetCollectionForRead autoColl(opCtx, {op.getNss().db().toString(), *uuid});
+ uassert(ErrorCodes::NamespaceNotFound, "Collection does not exist", autoColl);
+ // During tenant migration oplog application, we only need to apply createIndex on empty
+ // collections. Otherwise, the index is guaranteed to be dropped after. This is because
+ // we block index builds on the donor for the duration of the tenant migration.
+ if (!Helpers::findOne(
+ opCtx, autoColl.getCollection(), BSONObj(), false /* requireIndex */)
+ .isNull()) {
+ LOGV2_DEBUG(5652701,
+ 2,
+ "Tenant migration ignoring createIndex for non-empty collection",
+ "op"_attr = redact(op.toBSONForLogging()),
+ "tenant"_attr = _tenantId,
+ "migrationUuid"_attr = _migrationUuid);
+ return Status::OK();
+ }
+ } catch (const ExceptionFor<ErrorCodes::NamespaceNotFound>&) {
// If the collection doesn't exist, it is safe to ignore.
return Status::OK();
}
- // During tenant migration oplog application, we only need to apply createIndex on empty
- // collections. Otherwise, the index is guaranteed to be dropped after. This is because we
- // block index builds on the donor for the duration of the tenant migration.
- if (!Helpers::findOne(opCtx, autoColl.getCollection(), BSONObj(), false /* requireIndex */)
- .isNull()) {
- LOGV2_DEBUG(5652701,
- 2,
- "Tenant migration ignoring createIndex for non-empty collection",
- "op"_attr = redact(op.toBSONForLogging()),
- "tenant"_attr = _tenantId,
- "migrationUuid"_attr = _migrationUuid);
- return Status::OK();
- }
}
// We don't count tenant application in the ops applied stats.
auto incrementOpsAppliedStats = [] {};